Extracts the value function from a solved model. Extracts the alpha vectors describing the value function. This is similar to policy() which in addition returns the action prescribed by the solution.
value_function(model, drop =TRUE)plot_value_function( model, projection =NULL, epoch =1, ylim =NULL, legend =TRUE, col =NULL, lwd =1, lty =1, ylab ="Value",...)
Arguments
model: a solved POMDP or MDP .
drop: logical; drop the list for converged converged, epoch-independent value functions.
projection: Sample in a projected belief space. See projection() for details.
epoch: the value function of what epoch should be plotted? Use 1 for converged policies.
ylim: the y limits of the plot.
legend: logical; show the actions in the visualization?
col: potting colors.
lwd: line width.
lty: line type.
ylab: label for the y-axis.
...: additional arguments are passed on to stats::line()
or `graphics::barplot()``.
Returns
the function as a matrix with alpha vectors as rows.
Details
Plots the value function of a POMDP solution as a line plot. The solution is projected on two states (i.e., the belief for the other states is held constant at zero). The value function can also be visualized using plot_belief_space().
Examples
data("Tiger")sol <- solve_POMDP(Tiger)sol
# value function for the converged solutionvalue_function(sol)plot_value_function(sol, ylim = c(0,20))## finite-horizon problemsol <- solve_POMDP(model = Tiger, horizon =3, discount =1, method ="enum")sol
# inspect the value function for all epochsvalue_function(sol)plot_value_function(sol, epoch =1, ylim = c(-5,25))plot_value_function(sol, epoch =2, ylim = c(-5,25))plot_value_function(sol, epoch =3, ylim = c(-5,25))## Not run:# using ggplot2 to plot the value function for epoch 3library(ggplot2)pol <- policy(sol)ggplot(pol[[3]])+ geom_segment(aes(x =0, y = `tiger-left`, xend =1, yend = `tiger-right`, color = action))+ coord_cartesian(ylim = c(-5,15))+ ylab("Value")+ xlab("Belief space")## End(Not run)