Skip to content
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

Default for :info ? #27

Open
MaximeBouton opened this issue Sep 20, 2019 · 4 comments
Open

Default for :info ? #27

MaximeBouton opened this issue Sep 20, 2019 · 4 comments

Comments

@MaximeBouton
Copy link
Contributor

When testing RLInterface on POMDPs#version-0.8 I am getting the following error:
KeyError: key :info not found
which results from a call to:

s, r, info = gen(DDNOut(:sp, :r, :info), env.problem, env.state, a, env.rng)

I realized there is no default for :info anymore: https://github.com/JuliaPOMDP/POMDPModelTools.jl/blob/master/src/info.jl#L84

  • Do we want a default that outputs nothing ?
  • If yes, what is the proper way to implement it?
    e.g. POMDPs.gen(out::DDNOut{(:sp,:o,:r,:info)}, m, s, a, rng) = (gen(out, m, s, a, rng)..., nothing) , but with a smarter way to handle all the combination for out
  • If not, what is the proper way to check if :info is available?
@zsunberg
Copy link
Member

oh, hmm... I didn't think about this. I don't think it's a good idea to provide an implementation for gen. I guess the best way would be, in RLInterface

if :info in nodenames(DDNStructure(m))
    sp, r, i = gen(DDNOut(:sp, :r, :info), m, s, a, rng)
else
    sp, r = gen(DDNOut(:sp, :r), m, s, a, rng)
    i = nothing
end

I think the compiler should be able to remove the dead branch.

This is a little ugly, so maybe we should make something nicer eventually, like a DDNAll(m) that returns a NamedTuple, maybe even with defaults like DDNAll(m, info=nothing)

@MaximeBouton
Copy link
Contributor Author

That is what I was looking for thanks. I don't think the compiler is able to do that since now it is breaking the type stability tests. I will try to find a better way.

@MaximeBouton
Copy link
Contributor Author

I found a way to keep the type stability but it seems a bit hacky.
I added a parameter Info to MDPEnvironment that I set to true or false at construction if info is available.
See JuliaPOMDP/RLInterface.jl@f4668fc

@zsunberg
Copy link
Member

Maybe in POMDPModelTools there should be a wrapper that adds a node if it doesn't exist, i.e.

wrapper = assure_hasnodes(pomdp, (:info=>nothing, :c=>0.0))

If pomdp already has :info and :c nodes, then it just passes it through; if it does not it creates a new POMDP that behaves like the old one, except it has nodes :info and :c with defaults nothing and 0.0 respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants