Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added default_action option to DPWSolver (#37)
* added default_action option to DPWSolver * fixed errors
- Loading branch information
Showing
6 changed files
with
94 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
struct ExceptionRethrow end | ||
|
||
default_action(::ExceptionRethrow, mdp, s, ex) = rethrow(ex) | ||
default_action(f::Function, mdp, s, ex) = f(s, ex) | ||
default_action(p::POMDPs.Policy, mdp, s, ex) = action(p, s) | ||
default_action(sol::POMDPs.Solver, mdp, s, ex) = action(solve(sol, mdp), s) | ||
default_action(a, mdp, s, ex) = a | ||
|
||
""" | ||
ReportWhenUsed(a) | ||
When the planner fails, returns action `a`, but also prints the exception. | ||
""" | ||
struct ReportWhenUsed{T} | ||
a::T | ||
end | ||
|
||
function default_action(r::ReportWhenUsed, mdp, s, ex) | ||
showerror(STDERR, ex) | ||
a = default_action(r.a, mdp, s, ex) | ||
warn("Using default action $a") | ||
return a | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters