Solve the optimal control problem using policy iteration, i.e. find the optimal strategy and value function for the case where the uncontrolled system is given by a generator G0

PolicyIterationSingular(
  G0,
  G1,
  k,
  uopt,
  iter.max = 1000,
  tol = 1e-12,
  do.minimize = TRUE
)

Arguments

G0

The generator of the uncontrolled system

G1

A list of generators for each control

k

The running cost

uopt

A list of functions returning optional controls as function of

iter.max

= 1000 Maximum number of iterations

tol

= 1e-12 Tolerance for convergence

do.minimize=TRUE

Value

A list containing V: The value function, as a vector with an element for each state u: The optimal controls, as a matrix with a row for each state and a column for each control pi: The stationary distribution for the controlled system gamma: The expected running cost in stationarity

Examples

require(SDEtools)

u <- function(x)0*x
D <- function(x) 0*x + 0.25


xi <- seq(-2,2,length=201)
xc <- 0.5*(head(xi,-1) + tail(xi,-1))

G0 <- fvade(u,D,xi,'r')
Gp <- fvade(function(x)1,function(x)0,xi,'r')
Gn <- fvade(function(x)-1,function(x)0,xi,'r')

uopt <- function(Wp) pmax(0,-Wp)
k <- function(u) 0.5*xc^2 + 0.5*u[,1]^2 + 0.5*u[,2]^2

sol <- PolicyIterationSingular(G0,list(Gp,Gn),k,list(uopt,uopt))

par(mfrow=c(1,2))
plot(xc,sol$V,type="l",xlab="x",ylab="Value function")
plot(function(x)0.5*x^2+min(sol$V),from=-2,to=2,lty="dashed",add=TRUE)
plot(xc,sol$u[,1]-sol$u[,2],type="l",xlab="x",ylab="Control")
abline(0,-1,lty="dashed")