1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
\r
2 // Copyright (C) 2009 - DIGITEO - Michael Baudin
\r
3 // Copyright (C) 2010 - DIGITEO - Allan CORNET
\r
4 // Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
\r
6 // This file must be used under the terms of the CeCILL.
\r
7 // This source file is licensed as described in the file COPYING, which
\r
8 // you should have received as part of this distribution. The terms
\r
9 // are also available at
\r
10 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
\r
13 function demo_fmin_tolx()
\r
15 mprintf(_("Running optimization ...\n"));
\r
17 function y = banana (x)
\r
18 y = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
\r
22 opt = optimset ( "TolX" , 1.e-2 );
\r
23 [x , fval , exitflag , output] = fminsearch ( banana , x0 , opt );
\r
28 mprintf("x = %s\n",strcat(string(x)," "));
\r
29 mprintf("fval = %e\n",fval);
\r
30 mprintf("exitflag = %d\n",exitflag);
\r
31 mprintf("output.message:\n");
\r
34 mprintf(output.message(i));
\r
38 mprintf("output.algorithm:%s\n",output.algorithm);
\r
39 mprintf("output.funcCount:%d\n",output.funcCount);
\r
40 mprintf("output.iterations:%d\n",output.iterations);
\r
43 // Load this script into the editor
\r
45 m = messagebox(_("View Code?"), "Question", "question", [_("Yes") _("No")], "modal")
\r
47 filename = 'fminsearch_tolx.sce';
\r
48 dname = get_absolute_file_path(filename);
\r
49 editor ( dname + filename, "readonly" );
\r
54 clear demo_fmin_tolx;
\r