Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Commit

Permalink
fixed subtle type stability issues with the rollout sim
Browse files Browse the repository at this point in the history
  • Loading branch information
zsunberg committed Jul 28, 2017
1 parent 960c6ca commit 2a35eaf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/simulators/rollout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@ end
function simulate{S}(sim::RolloutSimulator, pomdp::POMDP{S}, policy::Policy, updater::Updater, initial_belief)

if !isnull(sim.initial_state)
s = get(sim.initial_state)::S
s = convert(S, get(sim.initial_state))::S
else
s = rand(sim.rng, initial_belief)
s = rand(sim.rng, initial_belief)::S
end

return simulate(sim, pomdp, policy, updater, initial_belief, s)
end

function simulate(sim::RolloutSimulator, pomdp::POMDP, policy::Policy, updater::Updater, initial_belief, s)

eps = get(sim.eps, 0.0)
max_steps = get(sim.max_steps, typemax(Int))

Expand Down
3 changes: 3 additions & 0 deletions test/test_rollout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ let
sim = RolloutSimulator(max_steps=10, rng=MersenneTwister(1))
r1 = @inferred simulate(sim, problem, policy, updater(policy), initial_state_distribution(problem))

sim = RolloutSimulator(max_steps=10, rng=MersenneTwister(1), initial_state=true)
dummy = @inferred simulate(sim, problem, policy, updater(policy), nothing)

problem = GridWorld()
solver = RandomSolver(rng=MersenneTwister(1))
policy = solve(solver, problem)
Expand Down

0 comments on commit 2a35eaf

Please sign in to comment.