JuliaPOMDP / RockSample.jl

Implement the rock sample problem using POMDPs.jl
Other
5 stars 5 forks source link

No method matching initialstate_distribution #9

Closed KMD2 closed 4 years ago

KMD2 commented 4 years ago

Hello, I tried running the example provided in the README.md:

using POMDPs
using RockSample 
using SARSOP # load a  POMDP Solver
using POMDPGifs # to make gifs

pomdp = RockSamplePOMDP(rocks_positions=[(2,3), (4,4), (4,2)], 
                        sensor_efficiency=20.0,
                        discount_factor=0.95, 
                        good_rock_reward = 20.0)

solver = SARSOPSolver(precision=1e-3)

policy = solve(solver, pomdp)

sim = GifSimulator(filename="test.gif", max_steps=30)
simulate(sim, pomdp, policy)

and I got the following error:

Generating a pomdpx file: model.pomdpx
MethodError: no method matching initialstate_distribution(::RockSamplePOMDP{3})
Closest candidates are:
  initialstate_distribution(!Matched::TigerPOMDP) at /Users/duoaakhalifa/.julia/packages/POMDPModels/EBkc5/src/TigerPOMDPs.jl:83
  initialstate_distribution(!Matched::SimpleGridWorld) at /Users/duoaakhalifa/.julia/packages/POMDPModels/EBkc5/src/gridworld.jl:127
  initialstate_distribution(!Matched::BabyPOMDP) at /Users/duoaakhalifa/.julia/packages/POMDPModels/EBkc5/src/CryingBabies.jl:88
  ...

Stacktrace:
 [1] belief_xml(::RockSamplePOMDP{3}, ::POMDPXFiles.POMDPXFile, ::IOStream) at /Users/duoaakhalifa/.julia/packages/POMDPXFiles/9uhIS/src/writer.jl:201
 [2] write(::RockSamplePOMDP{3}, ::POMDPXFiles.POMDPXFile) at /Users/duoaakhalifa/.julia/packages/POMDPXFiles/9uhIS/src/writer.jl:91
 [3] POMDPFile(::RockSamplePOMDP{3}, ::String; verbose::Bool) at /Users/duoaakhalifa/.julia/packages/SARSOP/NK0Yp/src/file.jl:24
 [4] solve(::SARSOPSolver, ::RockSamplePOMDP{3}; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/duoaakhalifa/.julia/packages/SARSOP/NK0Yp/src/solver.jl:64
 [5] solve(::SARSOPSolver, ::RockSamplePOMDP{3}) at /Users/duoaakhalifa/.julia/packages/SARSOP/NK0Yp/src/solver.jl:61
 [6] top-level scope at In[26]:13
 [7] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1091

May you kindly assist me with this?

MaximeBouton commented 4 years ago

Most likely a version issue, can you share the output of ] st in the julia REPL?

KMD2 commented 4 years ago

I ran the st command and got this error ERROR: UndefVarError: st not defined.

Below are the versioninfo:

Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
MaximeBouton commented 4 years ago

you have to be in package mode to run st , use ] to switch to package mode. Alternatively using Pkg; Pkg.status()

KMD2 commented 4 years ago

Oh, I see, here is the output:

Status `~/.julia/environments/v1.5/Project.toml`
  [8bb6e9a1] BeliefUpdaters v0.1.2
  [4b033969] DiscreteValueIteration v0.4.3
  [7073ff75] IJulia v1.21.2
  [d9ec5142] NamedTupleTools v0.11.0
  [7f35509c] POMDPGifs v0.1.0
  [08074719] POMDPModelTools v0.2.4
  [355abbd5] POMDPModels v0.4.8
  [182e52fb] POMDPPolicies v0.3.3
  [e0d0a172] POMDPSimulators v0.3.5
  [92e6a534] POMDPTesting v0.2.2
  [0729bffe] POMDPToolbox v0.3.0
  [a93abf59] POMDPs v0.8.4
  [438e738f] PyCall v1.91.4
  [3aa3ecc9] QMDP v0.1.2
  [8af83fb2] QuickPOMDPs v0.2.4 `https://github.com/JuliaPOMDP/QuickPOMDPs.jl.git#master`
  [de008ff0] RockSample v0.1.2 `https://github.com/JuliaPOMDP/RockSample.jl#master`
  [cef570c6] SARSOP v0.5.2
  [9a3f8284] Random
  [cf7118a7] UUIDs
MaximeBouton commented 4 years ago

Thanks, between POMDPs 0.8 and 0.9 the function initialstate_distribution has been replaced by initialstate, you can either downgrade RockSample to an earlier version, or upgrade POMDPs.jl (preferred).

To upgrade POMDPs.jl you can run the following: using Pkg; Pkg.update("POMDPs") which should install v0.9.

I will fix the version specification in this package so that this issue does not happen in future version. Could you please let me know if that fixes the issue? Thanks

MaximeBouton commented 4 years ago

Sorry, I re-read your error message and I think SARSOP should be updated as well. using Pkg; Pkg.update("SARSOP")

If you want to update everything you can just run Pkg.update()

KMD2 commented 4 years ago

I updated everything, it works perfectly now! Thank you very much.