Visualization
POMDPModelTools contains a basic visualization interface consisting of the render
function.
Problem writers should implement a method of this function so that their problem can be visualized in a variety of contexts including jupyter notebooks, web browsers, or saved as images or animations.
POMDPModelTools.render
— Functionrender(m::Union{MDP,POMDP}, step::NamedTuple)
Return a renderable representation of the step in problem m
.
The renderable representation may be anything that has show(io, mime, x)
methods. It could be a plot, svg, Compose.jl context, Cairo context, or image.
Arguments
step
is a NamedTuple
that contains the states, action, etc. corresponding to one transition in a simulation. It may have the following fields:
t
: the time step indexs
: the state at the beginning of the stepa
: the actionsp
: the state at the end of the step (s')r
: the reward for the stepo
: the observationb
: the belief at thebp
: the belief at the end of the stepi
: info from the model when the state transition was calculatedai
: info from the policy decisionui
: info from the belief update
Keyword arguments are reserved for the problem implementer and can be used to control appearance, etc.
Important Notes
step
may not contain all of the elements listed above, sorender
should check for them and render only what is availableo
typically corresponds tosp
, so it is often clearer for POMDPs to rendersp
rather thans
.
Sometimes it is important to have control over how the problem is rendered with different mimetypes. One way to handle this is to have render return a custom type, e.g.
struct MyProblemVisualization
mdp::MyProblem
step::NamedTuple
end
POMDPModelTools.render(mdp, step) = MyProblemVisualization(mdp, step)
and then implement custom show
methods, e.g.
show(io::IO, mime::MIME"text/html", v::MyProblemVisualization)