Skip to content

Commit

Permalink
new_node prevents repeat of simulate line
Browse files Browse the repository at this point in the history
  • Loading branch information
zsunberg committed Feb 16, 2018
1 parent 6cc883a commit cbc11a9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/dpw.jl
Expand Up @@ -115,6 +115,7 @@ function simulate(dpw::DPWPlanner, snode::Int, d::Int)
a = tree.a_labels[sanode]

# state progressive widening
new_node = false
if length(tree.transitions[sanode]) <= sol.k_state*tree.n[sanode]^sol.alpha_state

sp, r = generate_sr(dpw.mdp, s, a, dpw.rng)
Expand All @@ -127,16 +128,17 @@ function simulate(dpw::DPWPlanner, snode::Int, d::Int)

if spnode == 0 # there was not a state node for sp already in the tree
spnode = insert_state_node!(tree, sp, sol.keep_tree || sol.check_repeat_state)
new_node = true
end
push!(tree.transitions[sanode], (spnode, r))

if tree.total_n[spnode] == 0
q = r + discount(dpw.mdp)*estimate_value(dpw.solved_estimate, dpw.mdp, sp, d-1)
else
q = r + discount(dpw.mdp)*simulate(dpw, spnode, d-1)
end
else
(spnode, r) = rand(dpw.rng, tree.transitions[sanode])
spnode, r = rand(dpw.rng, tree.transitions[sanode])
end

if new_node
q = r + discount(dpw.mdp)*estimate_value(dpw.solved_estimate, dpw.mdp, sp, d-1)
else
q = r + discount(dpw.mdp)*simulate(dpw, spnode, d-1)
end

Expand Down

0 comments on commit cbc11a9

Please sign in to comment.