## adaptively manage the epidemic with the following
## initial population
init <- list(S0=762, I0=1, R0=0, D0=0)
## construct a grid of valid vaccination strategies
## and specify costs
## using a smaller grid for faster check times; try the commented out
## setting for higher fidelity
vacgrid <- list(fracs=seq(0,1.0,0.25), stops=seq(2,init$S0-75,150))
## vacgrid <- list(fracs=seq(0,1.0,0.1), stops=seq(2,init$S0-75,75))
costs <- list(vac=2, death=4, infect=1)
## run the Monte Carlo management experiment, reducing MCMCpits
## for faster check times; try default (commented out) version
out.MCmanage <- MCmanage(init, epistep, vacgrid, costs,
MCMCpits=100, MCreps=5)
## out.MCmanage <- MCmanage(init, epistep, vacgrid, costs)
## plot the trajectories of SIR and the associated costs
plot(out.MCmanage, main="optimal adaptive vaccination")
plot(out.MCmanage, type="costs")
## extract the distribution of the number of
## cumulative vaccinations via median and quantiles
getvac(out.MCmanage)
## plot the distribution fractions vaccinated and
## stopping times
plot(out.MCmanage, type="fracs")
plot(out.MCmanage, type="stops")
## get the final median cost and quantiles --
## these can be compared with the static ones
## calculated by MCepi
getcost(out.MCmanage)
Run the code above in your browser using DataLab