if (FALSE) {
#------------------------------------------------------------
# Maximization with POO
#------------------------------------------------------------
set.seed(10)
noise.level <- 0.05
## Define and display objective
ftest <- function(x){return(double_sine(x) + runif(1, min = -noise.level, max = noise.level))}
xgrid <- seq(0, 1, length.out = 1000)
plot(xgrid, sapply(xgrid, double_sine), type = 'l', ylab = "double_sine(x)", xlab = 'x')
## Optimization
Sol <- POO(ftest, horizon = 1000, noise.level = noise.level)
## Display result
abline(v = Sol$par)
}
Run the code above in your browser using DataLab