JuliaPOMDP / DiscreteValueIteration.jl

Value iteration solver for MDPs
Other
20 stars 12 forks source link

No method matching states(::MyMDP) #12

Closed maxmouchet closed 7 years ago

maxmouchet commented 7 years ago

Hi,

When I run @requirements_info on this minimal example, it says states and n_states are not defined. But they are. Or have I missed something ?

This is on Julia v0.5 and POMDPs v0.4.1.

using POMDPs
using DiscreteValueIteration

type MyMDP <: MDP{Int64, Bool} end

states(::MyMDP) = [0, 1, 2, 3]
n_states(::MyMDP) = 4

@requirements_info ValueIterationSolver() MyMDP()
For solve(::ValueIterationSolver, ::Union{MDP,POMDP}):
  [✓] discount(::MyMDP)
  [X] n_states(::MyMDP)
  [✓] n_actions(::MyMDP)
  [X] transition(::MyMDP, ::Int64, ::Bool)
  [X] reward(::MyMDP, ::Int64, ::Bool, ::Int64)
  [✓] state_index(::MyMDP, ::Int64)
  [✓] action_index(::MyMDP, ::Bool)
  [✓] actions(::MyMDP, ::Int64)
  WARNING: Some requirements may not be shown because a MethodError was thrown.
For ordered_states(::Union{MDP,POMDP}) (in solve(::ValueIterationSolver, ::Union{MDP,POMDP})):
  [X] states(::MyMDP)
zsunberg commented 7 years ago

Hi Maxime,

You need to write a new method for states in the POMDPs namespace. You need to either need to

1) explicitly import the function from POMDPs, i.e. use importall POMDPs instead of using POMDPs, or 2) use the fully-qualified method name, i.e.

using POMDPs

type MyMDP <: MDP{Int64, Bool} end

POMDPs.states(::MyMDP) = [0, 1, 2, 3]

Hope that helps!

maxmouchet commented 7 years ago

Ok, I understand, it's working now. Thanks for your time!

zsunberg commented 7 years ago

Cool, good to hear you got it working