1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2008-2009 - INRIA - Michael Baudin
3// Copyright (C) 2011 - DIGITEO - Michael Baudin
4//
5// Copyright (C) 2012 - 2016 - Scilab Enterprises
6//
7// This file is hereby licensed under the terms of the GNU GPL v2.0,
8// pursuant to article 5.3.4 of the CeCILL v.2.1.
9// This file was originally licensed under the terms of the CeCILL v2.1,
10// and continues to be available under such terms.
11// For more information, see the COPYING file which you should have received
12// along with this program.
13// <-- CLI SHELL MODE -->
14// <-- ENGLISH IMPOSED -->
15function [ y , index ] = rosenbrock ( x , index )
16  y = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
17endfunction
18nm = neldermead_new ();
19nm = neldermead_configure(nm,"-numberofvariables",2);
20nm = neldermead_configure(nm,"-x0",[1.0 2.0]');
21nm = neldermead_configure(nm,"-simplex0method","axes");
22nm = neldermead_configure(nm,"-simplex0length",1.0);
23nm = neldermead_configure(nm,"-function",rosenbrock);
24nm = neldermead_search(nm, "off");
25simplex = neldermead_get(nm,"-simplex0");
26computed = optimsimplex_getallx( simplex );
27expected = [
28    1.    2.
29    2.    2.
30    1.    3.
31];
32assert_checkalmostequal ( computed , expected, %eps );
33nm = neldermead_destroy(nm);
34