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 --> 15// 16// Check behaviour with default settings. 17// 18function [ y , index ] = rosenbrock ( x , index ) 19 y = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2; 20endfunction 21// 22// Test tolerance on variance of function values 23// 24nm = neldermead_new (); 25nm = neldermead_configure(nm,"-numberofvariables",2); 26nm = neldermead_configure(nm,"-function",rosenbrock); 27nm = neldermead_configure(nm,"-x0",[-1.2 1.0]'); 28nm = neldermead_configure(nm,"-maxiter",600); 29nm = neldermead_configure(nm,"-maxfunevals",600); 30nm = neldermead_configure(nm,"-tolfunmethod",%f); 31nm = neldermead_configure(nm,"-tolxmethod",%f); 32nm = neldermead_configure(nm,"-tolvarianceflag",%t); 33WARNING: Option -tolvarianceflag is obsolete. 34WARNING: Please use -outputcommand instead. 35WARNING: This feature will be permanently removed in Scilab 5.4.1 36nm = neldermead_configure(nm,"-tolabsolutevariance",1.e-4); 37WARNING: Option -tolabsolutevariance is obsolete. 38WARNING: Please use -outputcommand instead. 39WARNING: This feature will be permanently removed in Scilab 5.4.1 40nm = neldermead_configure(nm,"-tolrelativevariance",1.e-4); 41WARNING: Option -tolrelativevariance is obsolete. 42WARNING: Please use -outputcommand instead. 43WARNING: This feature will be permanently removed in Scilab 5.4.1 44nm = neldermead_configure(nm,"-simplex0method","axes"); 45nm = neldermead_configure(nm,"-simplex0length",1.0); 46nm = neldermead_configure(nm,"-method","variable"); 47nm = neldermead_search(nm); 48// Check optimum point 49fopt = neldermead_get(nm,"-fopt"); 50assert_checkalmostequal ( fopt , 4.0, 1e-1 ); 51// Check status 52status = neldermead_get(nm,"-status"); 53assert_checkequal ( status , "tolvariance" ); 54nm = neldermead_destroy(nm); 55