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

Function convert_s error #452

Closed
yangyou95 opened this issue Dec 13, 2022 · 2 comments
Closed

Function convert_s error #452

yangyou95 opened this issue Dec 13, 2022 · 2 comments

Comments

@yangyou95
Copy link

yangyou95 commented Dec 13, 2022

I'm learning how to use this POMDPs.jl framework (which is amazing!) and I'm really new to Julia, maybe this is a stupid question.

According to the documentation (https://juliapomdp.github.io/POMDPs.jl/latest/api/#POMDPs.convert_s),
This convert_s(::Type{V}, s, POMDP) function should output a vector, which corresponds to the state s in the given POMDP.
For example, like "vector<double>" in c++.

However, I run the following codes, it seems this transformation is not allowed?

# -- RockSample (15, 15) ---
pomdp = RockSamplePOMDP(15, 15)
b0 = initialstate(pomdp)
s = rand(b0)
println(s)
convert_s(Vector{Float64}, s, pomdp)

### output ###
ERROR: MethodError: no method matching convert_s(::Type{Vector{Float64}}, ::RSState{15}, ::RockSamplePOMDP{15})
Closest candidates are:
  convert_s(::Type{A1}, ::A2, ::Union{MDP, POMDP}) where {A1<:AbstractArray, A2<:AbstractArray} at C:\Users\Yang\.julia\packages\POMDPs\XBTe5\src\pomdp.jl:153
  convert_s(::Type{V}, ::Any, ::FullyObservablePOMDP) where V<:AbstractArray at C:\Users\Yang\.julia\packages\POMDPTools\i3nmI\src\ModelTools\fully_observable_pomdp.j
l:39
  convert_s(::Type{A}, ::Number, ::Union{MDP, POMDP}) where A<:AbstractArray at 
  ...
Stacktrace:

Did I miss something? I just would like to transform any given state s in any (PO)MDP into a vector<double>, so that the solver could be generic to handle different problems.

Thanks for your help.

@zsunberg
Copy link
Member

zsunberg commented Dec 13, 2022

Hi @yangyou95 , you are understanding the usage correctly. The issue is that RockSample does not implement convert_s at the moment. The problems in POMDPs.jl have varying levels of completeness in implementing the entire interface, and this one just doesn't have convert_s.

The implementation should look something like:

POMDPs.convert_s(T::Type{<:AbstractArray}, s::RSState, m::RockSamplePOMDP) = convert(T, vcat(s.pos, s.rocks))

If you want to submit a PR to RockSample.jl to add it and test it, that would be really helpful. Otherwise I might be able to get around to it sometime soon

@yangyou95
Copy link
Author

Thanks for the explanation! I will work on that.

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