Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- one_plus_one<-function(f,sigma,nbEvals,precision){
- m=runif(2,min = -5,max = 5)
- i=0
- out<-f(m)
- repeat{
- x1 = m[1] +rnorm(n=1, mean=0,sd=sigma)
- x2 = m[2]+rnorm(n=1, mean=0,sd=sigma)
- #cat(f(c(x1,x2)),"//",f(m),"||")
- if(f(c(x1,x2)) < f(m)){
- m<-c(x1,x2)
- sigma=sigma*exp(1/3)
- }else{
- sigma=sigma/exp(1/4)^(1/4)
- }
- out<-c(out,f(m))
- i <- i + 1
- if (i>nbEvals | f(m)<precision){break}
- }
- return(out)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement