Learn R Programming

pomdp (version 1.0.2)

plot_value_function: Plot the Value Function of a POMDP Solution

Description

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).

Usage

plot_value_function(
  model,
  projection = 1:2,
  epoch = 1,
  ylim = NULL,
  legend = TRUE,
  col = NULL,
  lwd = 1,
  lty = 1,
  ...
)

Arguments

model

a solved POMDP.

projection

index or name of two states for the projection.

epoch

the value function of what epoch should be plotted? Use 1 for converged policies.

ylim

the y limits of the plot.

legend

logical; add a legend?

col

potting colors.

lwd

line width.

lty

line type.

...

additional arguments are passed on to stats::line()`.

Value

the function has no return value.

See Also

Other policy: optimal_action(), policy_graph(), policy(), reward(), solve_POMDP(), solve_SARSOP()

Examples

Run this code
# NOT RUN {
data("Tiger")
sol <- solve_POMDP(model = Tiger)
sol

plot_value_function(sol, ylim = c(0,20))

## finite-horizon
sol <- solve_POMDP(model = Tiger, horizon = 3, discount = 1,
  method = "enum")
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))

# using ggplot2
# library(ggplot2)
# pol <- policy(sol)[[3]]
# ggplot(pol) + 
#   geom_segment(aes(x = 0, y = `tiger-left`, xend=1, yend=`tiger-right`, color = action)) + 
#   coord_cartesian(ylim = c(-5, 15)) + ylab("Reward") + xlab("Belief")
# }

Run the code above in your browser using DataLab