Advertisement
Guest User

Untitled

a guest
May 21st, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. eval_f<-function(x){
  2. return(100*(x[2]-x[1]*x[1])^2+(1-x[1])^2)
  3. }
  4. eval_grad_f<-function(x){
  5. return(c(400*x[1]*x[2]-x[1]*x[1]-2*(1-x[1]),
  6. 200*(x[2]-x[1]*x[1])))
  7. }
  8. library(nloptr)
  9. x0<-c(-1,2,1)
  10. opts<-list("algorithm"="NLOPT_LD_LBFGS",
  11. "xtol_res"=1.0e-8)
  12. res<-nloptr(x0=x0,
  13. eval_f=eval_f,
  14. eval_g=eval_g,
  15. opts=opts)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement