-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POMDPs v0.8 Compatibility #26
Changes from 1 commit
545fd3e
7ee8c29
d621206
5d007da
3052882
3fc9564
d5f2579
fd95118
56c6cdb
44cf4cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,6 @@ | ||
# functions for passing out info from simulations, similar to the info return from openai gym | ||
# maintained by @zsunberg | ||
|
||
""" | ||
Return a tuple containing the next state and reward and information (usually a `NamedTuple`, `Dict` or `nothing`) from that step. | ||
|
||
By default, returns `nothing` as info. | ||
""" | ||
function generate_sri(p::MDP, s, a, rng::AbstractRNG) | ||
return generate_sr(p, s, a, rng)..., nothing | ||
end | ||
|
||
""" | ||
Return a tuple containing the next state, observation, and reward and information (usually a `NamedTuple`, `Dict` or `nothing`) from that step. | ||
|
||
By default, returns `nothing` as info. | ||
""" | ||
function generate_sori(p::POMDP, s, a, rng::AbstractRNG) | ||
return generate_sor(p, s, a, rng)..., nothing | ||
end | ||
|
||
""" | ||
a, ai = action_info(policy, x) | ||
|
||
|
@@ -51,3 +33,49 @@ By default, returns `nothing` as info. | |
function update_info(up::Updater, b, a, o) | ||
return update(up, b, a, o), nothing | ||
end | ||
|
||
""" | ||
add_infonode(ddn::DDNStructure) | ||
|
||
Create a new DDNStructure object with a new node labeled :info with parents :s and :a | ||
""" | ||
function add_infonode(ddn) # for DDNStructure, but it is not declared in v0.7.3, so there is not annotation | ||
add_node(ddn, :info, ConstantDDNNode(nothing), (:s, :a)) | ||
end | ||
|
||
function add_infonode(ddn::POMDPs.DDNStructureV7{nodenames}) where nodenames | ||
return POMDPs.DDNStructureV7{(nodenames..., :info)}() | ||
end | ||
|
||
############################################################### | ||
# Note all generate functions will be deprecated in POMDPs v0.8 | ||
############################################################### | ||
|
||
|
||
if DDNStructure(MDP) isa POMDPs.DDNStructureV7 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't we check on the POMDPs.jl version instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's what I initially though, but it didn't seem like there was a good way to do that, so this seems like a reliable enough proxy There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how to reply to your comment on this below. The problem with Pkg.installed() is that it can take a really long time (or at least it could in the past) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and it adds Pkg as a dependency (which is probably fine) |
||
""" | ||
Return a tuple containing the next state and reward and information (usually a `NamedTuple`, `Dict` or `nothing`) from that step. | ||
|
||
By default, returns `nothing` as info. | ||
""" | ||
function generate_sri(p::MDP, s, a, rng::AbstractRNG) | ||
return generate_sr(p, s, a, rng)..., nothing | ||
end | ||
|
||
""" | ||
Return a tuple containing the next state, observation, and reward and information (usually a `NamedTuple`, `Dict` or `nothing`) from that step. | ||
|
||
By default, returns `nothing` as info. | ||
""" | ||
function generate_sori(p::POMDP, s, a, rng::AbstractRNG) | ||
return generate_sor(p, s, a, rng)..., nothing | ||
end | ||
|
||
POMDPs.gen(::DDNOut{(:sp,:o,:r,:i)}, m, s, a, rng) = generate_sori(m, s, a, rng) | ||
POMDPs.gen(::DDNOut{(:sp,:o,:r,:info)}, m, s, a, rng) = generate_sori(m, s, a, rng) | ||
POMDPs.gen(::DDNOut{(:sp,:r,:i)}, m, s, a, rng) = generate_sri(m, s, a, rng) | ||
POMDPs.gen(::DDNOut{(:sp,:r,:info)}, m, s, a, rng) = generate_sri(m, s, a, rng) | ||
else | ||
@deprecate generate_sri(args...) gen(DDNOut(:sp,:r,:info), args...) | ||
@deprecate generate_sori(args...) gen(DDNOut(:sp,:o,:r,:info), args...) | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,4 +73,4 @@ using SparseArrays | |
include("test_tabular.jl") | ||
end | ||
|
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
let | ||
mdp = GridWorld() | ||
mdp = SimpleGridWorld() | ||
|
||
pomdp = FullyObservablePOMDP(mdp) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be valuable to have the example from the conversation in here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 it is in the docstring now