Skip to content

Commit

Permalink
made minimal_example easier to understand
Browse files Browse the repository at this point in the history
  • Loading branch information
zsunberg committed Nov 16, 2017
1 parent 1e3c8a5 commit 7874884
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion notebooks/Minimal_Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"source": [
"## Reliable Belief Updates\n",
"\n",
"This model has a small enough observation space to be used with the default unweighted rejection-based particle filter. In most cases we need to use a weighted particle filter, which will require definition of the observation distribution."
"By default, if the POMDP does not have an explicit observation model implemented (`POMDPs.observation()` or `ParticleFilters.obs_weight()`), POMCP will attempt to use the unweighted rejection particle filter defined here: https://github.com/JuliaPOMDP/ParticleFilters.jl/blob/master/src/unweighted.jl. Our `LightDark1D` POMDP has a small enough observation space for that to work, but in most cases, we will need to use a weighted particle filter, which will require definition of the observation distribution."
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/BasicPOMCP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ Partially Observable Monte Carlo Planning Solver. Options are set using the keyw
default_action::Any
Function, action, or Policy used to determine the action if POMCP fails with exception `ex`.
If this is a Function `f`, `f(belief, ex)` will be called.
If this is a Function `f`, `f(pomdp, belief, ex)` will be called.
If this is a Policy `p`, `action(p, belief)` will be called.
If it is an object `a`, `default_action(a, belief, ex) will be called, and
If it is an object `a`, `default_action(a, pomdp, belief, ex) will be called, and
if this method is not implemented, `a` will be returned directly.
rng::AbstractRNG
Expand Down
11 changes: 6 additions & 5 deletions src/exceptions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ Base.show(io::IO, ast::AllSamplesTerminal) = print(io, """

immutable ExceptionRethrow end

default_action(::ExceptionRethrow, belief, ex) = rethrow(ex)
default_action(f::Function, belief, ex) = f(belief, ex)
default_action(p::POMDPs.Policy, belief, ex) = action(p, belief)
default_action(a, belief, ex) = a
default_action(::ExceptionRethrow, pomdp, belief, ex) = rethrow(ex)
default_action(f::Function, pomdp, belief, ex) = f(belief, ex)
default_action(p::POMDPs.Policy, pomdp, belief, ex) = action(p, belief)
default_action(s::POMDPs.Solver, pomdp, belief, ex) = action(solve(s, pomdp), belief)
default_action(a, pomdp, belief, ex) = a

"""
ReportWhenUsed(a)
Expand All @@ -34,7 +35,7 @@ immutable ReportWhenUsed{T}
a::T
end

function default_action(r::ReportWhenUsed, belief, ex)
function default_action(r::ReportWhenUsed, pomdp, belief, ex)
showerror(STDERR, ex)
warn("Using default action $(r.a)")
return r.a
Expand Down
2 changes: 1 addition & 1 deletion src/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function action(p::POMCPPlanner, b)
p._tree = Nullable(tree)
catch ex
# Note: this might not be type stable, but it shouldn't matter too much here
a = convert(action_type(p.problem), default_action(p.solver.default_action, b, ex))
a = convert(action_type(p.problem), default_action(p.solver.default_action, p.problem, b, ex))
end
return a
end
Expand Down

0 comments on commit 7874884

Please sign in to comment.