Can states be mutable? #527
-
The reason I would want this is to have an MDP that transitions to a terminated state after a non-zero reward is observed, something like this:
I'm not sure this would work. I could imagine mutating the current state could cause problems for some or all solvers. EDIT: I could also make the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You're correct! Mutating the state or mdp object will break most solvers. Philosophically, POMDPs.jl assumes that states and problems are immutable. This has significant performance and clarity advantages. You can still implement your desired behavior with an immutable state - you just have to make sure to decide if the problem is done within function transition(m, s, a)
... # generate new state here using (s, a)
done = reward(m, s, a) != 0
return Deterministic(MyState(..., done))
end (Also |
Beta Was this translation helpful? Give feedback.
You're correct! Mutating the state or mdp object will break most solvers. Philosophically, POMDPs.jl assumes that states and problems are immutable. This has significant performance and clarity advantages.
You can still implement your desired behavior with an immutable state - you just have to make sure to decide if the problem is done within
transition
. If thereward
function is not too expensive (and it usually isn't compared to other things involved in (PO)MDP solving), you could just do this:(Also
transition
should return a distr…