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
12 function demo_rosenbrock()
\r
14 mprintf(_("Running optimization ...\n"));
\r
16 function [ f , g , ind ] = rosenbrock ( x , ind )
\r
17 f = 100*(x(2)-x(1)^2)^2+(1-x(1))^2;
\r
18 g(1) = - 400. * ( x(2) - x(1)**2 ) * x(1) -2. * ( 1. - x(1) )
\r
19 g(2) = 200. * ( x(2) - x(1)**2 )
\r
23 [f, x] = optim(rosenbrock, x0);
\r
28 mprintf("x = %s\n", strcat(string(x)," "));
\r
29 mprintf("f = %e\n", f);
\r
32 // Load this script into the editor
\r
34 m = messagebox(_("View Code?"), "Question", "question", [_("Yes") _("No")], "modal")
\r
36 filename = 'optim_rosenbrock.sce';
\r
37 dname = get_absolute_file_path(filename);
\r
38 editor ( dname + filename );
\r
43 clear demo_rosenbrock;
\r