Skip to content

Commit

Permalink
Merge branch 'master' into exploration-policies
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximeBouton committed Mar 19, 2020
2 parents 7d8b5ca + 555637d commit faeaf75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/alpha_vector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ end

@deprecate AlphaVectorPolicy(pomdp::POMDP, alphas) AlphaVectorPolicy(pomdp, alphas, ordered_actions(pomdp))

AlphaVectorPolicy(m::POMDP, alphas::AbstractVector, amap) = AlphaVectorPolicy(m, length(states(m)), alphas, amap)
function AlphaVectorPolicy(m::POMDP, alphas::AbstractVector, amap)
AlphaVectorPolicy(m, length(states(m)), alphas,
convert(Vector{actiontype(m)}, amap))
end

# assumes alphas is |S| x (number of alpha vecs)
function AlphaVectorPolicy(p::POMDP, alphas::Matrix{Float64}, action_map)
Expand All @@ -39,7 +42,8 @@ function AlphaVectorPolicy(p::POMDP, alphas::Matrix{Float64}, action_map)
push!(alpha_vecs, vec(alphas[:,i]))
end

AlphaVectorPolicy(p, length(states(p)), alpha_vecs, action_map)
AlphaVectorPolicy(p, length(states(p)), alpha_vecs,
convert(Vector{actiontype(p)}, action_map))
end

updater(p::AlphaVectorPolicy) = DiscreteUpdater(p.pomdp)
Expand Down
4 changes: 4 additions & 0 deletions test/test_alpha_policy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ let

@test value(policy, b0) == 0.0
@test action(policy, b0) == true

# JuliaPOMDP/SARSOP.jl#39
policy = AlphaVectorPolicy(pomdp, alphas, convert(BitArray, ordered_actions(pomdp)))
policy = AlphaVectorPolicy(pomdp, collect(alphas[:, i] for i in 1:size(alphas, 2)), convert(BitArray, ordered_actions(pomdp)))
end

0 comments on commit faeaf75

Please sign in to comment.