Renamed mtlb_fminsearch into fminsearch. Added demos.
[scilab.git] / scilab / modules / optimization / demos / neldermead / neldermead_rosenbrock.sce
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2008-2009 - INRIA - Michael Baudin
3 //
4 // This file must be used under the terms of the CeCILL.
5 // This source file is licensed as described in the file COPYING, which
6 // you should have received as part of this distribution.  The terms
7 // are also available at
8 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
9
10 function y = rosenbrock (x)
11 y = 100*(x(2)-x(1)^2)^2+(1-x(1))^2;
12 endfunction
13
14 nm = neldermead_new ();
15 nm = neldermead_configure(nm,"-numberofvariables",2);
16 nm = neldermead_configure(nm,"-function",rosenbrock);
17 nm = neldermead_configure(nm,"-x0",[-1.2 1.0]');
18 nm = neldermead_configure(nm,"-maxiter",200);
19 nm = neldermead_configure(nm,"-maxfunevals",300);
20 nm = neldermead_configure(nm,"-tolfunrelative",10*%eps);
21 nm = neldermead_configure(nm,"-tolxrelative",10*%eps);
22 nm = neldermead_configure(nm,"-simplex0method","axes");
23 nm = neldermead_configure(nm,"-simplex0length",1.0);
24 nm = neldermead_configure(nm,"-method","variable");
25 nm = neldermead_configure(nm,"-verbose",0);
26 nm = neldermead_configure(nm,"-verbosetermination",0);
27 nm = neldermead_search(nm);
28
29 [nm , xdata , ydata , zdata ] = neldermead_contour ( nm , xmin = -2.0 , xmax = 2.0 , ymin = -2.0 , ymax = 2.0 , nx = 100 , ny = 100 );
30 contour ( xdata , ydata , zdata , 20 )
31
32
33
34 nm = neldermead_destroy(nm);
35 clear nm;
36
37