1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2011 - DIGITEO - Michael Baudin
3//
4// Copyright (C) 2012 - 2016 - Scilab Enterprises
5//
6// This file is hereby licensed under the terms of the GNU GPL v2.0,
7// pursuant to article 5.3.4 of the CeCILL v.2.1.
8// This file was originally licensed under the terms of the CeCILL v2.1,
9// and continues to be available under such terms.
10// For more information, see the COPYING file which you should have received
11// along with this program.
12
13// <-- CLI SHELL MODE -->
14// <-- ENGLISH IMPOSED -->
15
16//
17// Check behaviour with default output function.
18//
19
20function [ f , index ] = quadratic ( x , index )
21  f = x(1)^2 + x(2)^2;
22endfunction
23x0 = [1.0 1.0].';
24nm = neldermead_new ();
25nm = neldermead_configure(nm,"-numberofvariables",2);
26nm = neldermead_configure(nm,"-function",quadratic);
27nm = neldermead_configure(nm,"-x0",x0);
28nm = neldermead_configure(nm,"-outputcommand",neldermead_defaultoutput);
29nm = neldermead_search(nm, "off");
30// Check optimum point
31xopt = neldermead_get(nm,"-xopt");
32assert_checkalmostequal ( xopt , [0;0], [], 1e-6 );
33// Check status
34status = neldermead_get(nm,"-status");
35assert_checkequal ( status , "maxfuneval" );
36nm = neldermead_destroy(nm);
37
38