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_optim_output()
\r
14 mprintf(_("Running optimization ...\n"));
\r
19 function [f,g,ind] = cost(x,ind)
\r
20 if ( ind == 1 | ind == 4 ) then
\r
21 f = 0.5*norm(x-xref)^2;
\r
24 if ( ind == 1 | ind == 4 ) then
\r
28 if ( ind == 1 ) then
\r
29 mprintf("===========\n")
\r
30 mprintf("x = %s\n", strcat(string(x)," "))
\r
31 mprintf("f = %e\n", f)
\r
33 mprintf("g = %s\n", strcat(string(g)," "))
\r
38 [f, xopt] = optim(cost, x0, imp=-1)
\r
40 // Load this script into the editor
\r
42 m = messagebox(_("View Code?"), "Question", "question", [_("Yes") _("No")], "modal")
\r
44 filename = 'optim_output.sce';
\r
45 dname = get_absolute_file_path(filename);
\r
46 editor ( dname + filename );
\r
51 clear demo_optim_output;
\r