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