Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop num_actions from DiscreteDP #207

Merged
merged 3 commits into from
Jun 23, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/markov/ddp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ mutable struct DiscreteDP{T<:Real,NQ,NR,Tbeta<:Real,Tind,TQ<:AbstractArray{T,NQ}
if NR != 2
msg = "R must be 2-dimensional without s-a formulation"
throw(ArgumentError(msg))
end
end
(beta < 0 || beta >= 1) && throw(ArgumentError("beta must be [0, 1)"))

# verify input integrity 2
num_states, num_actions = size(R)
num_states, num_actions = size(R)
if size(Q) != (num_states, num_actions, num_states)
throw(ArgumentError("shapes of R and Q must be (n,m) and (n,m,n)"))
end

# check feasibility
R_max = s_wise_max(R)
if any(R_max .== -Inf)
Expand Down Expand Up @@ -215,7 +215,7 @@ const DDPsa{T,Tbeta,Tind,TQ} = DiscreteDP{T,2,1,Tbeta,Tind,TQ}

num_states(ddp::DDP) = size(ddp.R, 1)
num_states(ddp::DDPsa) = size(ddp.Q, 2)
num_actions(ddp::DiscreteDP) = size(ddp.R, 2)


abstract type DDPAlgorithm end
"""
Expand Down Expand Up @@ -577,7 +577,7 @@ end

"""
Return the `Vector` `max_a vals(s, a)`, where `vals` is represented as a
`AbstractMatrix` of size `(num_states, num_actions)`.
`AbstractMatrix` of size `(num_states, num_actions).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we need a closing backtick character after `num_actions)

"""
s_wise_max(vals::AbstractMatrix) = vec(maximum(vals, 2))

Expand All @@ -589,7 +589,7 @@ s_wise_max!(vals::AbstractMatrix, out::AbstractVector) = (println("calling this

"""
Populate `out` with `max_a vals(s, a)`, where `vals` is represented as a
`AbstractMatrix` of size `(num_states, num_actions)`.
`AbstractMatrix` of size `(num_states, num_actions).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about backtick here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, my bad. I will improve the formatting.


Also fills `out_argmax` with the column number associated with the `indmax` in
each row
Expand Down