Skip to content

Commit

Permalink
default actions
Browse files Browse the repository at this point in the history
  • Loading branch information
zsunberg committed Sep 8, 2017
1 parent 771c55b commit 407475b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/planner2.jl
Expand Up @@ -31,7 +31,13 @@ function action{P,NBU}(pomcp::POMCPOWPlanner{P,NBU}, b)
B = belief_type(NBU,P)
tree = POMCPOWTree{B,A,O,typeof(b)}(b, 2*pomcp.solver.tree_queries)
pomcp.tree = tree
return search(pomcp, tree)
local a::A
try
a = search(pomcp, tree)
catch ex
a = convert(A, default_action(pomcp.solver.default_action, b, ex))
end
return a
end

function search(pomcp::POMCPOWPlanner, tree::POMCPOWTree)
Expand Down
10 changes: 10 additions & 0 deletions test/runtests.jl
Expand Up @@ -3,6 +3,7 @@ using Base.Test

using POMDPModels
using POMDPToolbox
using ParticleFilters

solver = POMCPOWSolver()

Expand All @@ -16,3 +17,12 @@ b = initial_state_distribution(pomdp)
B = POMCPOW.belief_type(POMCPOW.POWNodeFilter, typeof(pomdp))
tree = POMCPOWTree{B,Bool,Bool,typeof(b)}(b, 2*planner.solver.tree_queries)
@inferred POMCPOW.simulate(planner, POMCPOW.POWTreeObsNode(tree, 1), true, 10)

let
pomdp = LightDark1D()
solver = POMCPOWSolver(default_action=485)
planner = solve(solver, pomdp)

b = ParticleCollection([LightDark1DState(-1, 0)])
@test action(planner, b) == 485
end

0 comments on commit 407475b

Please sign in to comment.