Dmitrey

bench 3 - intsolver

Mar 27th, 2011
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.62 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.  
  7. opts = intoptimset();
  8. opts(1) = 1e-2; % ftol
  9. x0 = [infsup(0,1), infsup(0,1), infsup(0,1),infsup(0,1), infsup(0,1), infsup(0,1), infsup(0,1)];
  10. tic
  11. x = intminunc(f, x0,opts)
  12. toc
  13.  
  14.  
  15. Output:
  16. ...
  17.  610     5701    4600    570     610     -6.338e+00      0   321     0.359
  18. ...
  19. >> toc
  20. Elapsed time is 339.014638 seconds.
Advertisement
Add Comment
Please, Sign In to add comment