Dmitrey

bench 3 - Direct

Mar 27th, 2011
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.61 KB | None | 0 0
  1. % I could use sum(vectorized_expr) but this form is more obvious
  2. f = @(x) cos(10*x(1))+(x(1)-0.01)^2 + cos(20*x(2)) + (x(2)-0.02)^2 + ...
  3.     cos(30*x(3)) + (x(3)-0.03)^2 + cos(40*x(4)) + (x(4)-0.04)^2 + ...
  4.     cos(50*x(5)) + (x(5)-0.05)^2 + cos(60*x(6)) + (x(6)-0.06)^2 + ...
  5.     cos(70*x(7)) + (x(7)-0.07)^2
  6. Problem.f = f;
  7. bounds = [zeros(1,7);ones(1,7)]';
  8. opts.tol = 1e-2;
  9. opts.maxevals = 100000;
  10. opts.maxits = 10000;
  11. tic
  12. [ret_minval,final_xatmin,history] = Direct(Problem,bounds,opts);
  13. toc
  14.  
  15. Output:
  16. ...
  17. Iter: 1132   f_min:   -6.7598445620    fn evals:    72997
  18. ...
  19. Elapsed time is 301.247543 seconds.
Advertisement
Add Comment
Please, Sign In to add comment