In the following example, neldermead reaches the maximum number of function evaluations (i.e. funevals=100), but does not produce a warning. Hence, the user might not be aware that the optimization failed. This is particularily true with neldermead, which does return the status of the optimization, but only optionnally. The neldermead component should produce warnings, but this should be an option, set to true by default: if the "warning" option is set to false, neldermead should not produce a warning.
function [f, index]=quadratic(x, index)
f = x(1)^2 + x(2)^2
endfunction
x0 = [1.0 1.0].';
nm = neldermead_new ();
nm = neldermead_configure(nm,"-numberofvariables",2);
nm = neldermead_configure(nm,"-function",quadratic);
nm = neldermead_configure(nm,"-x0",x0);
nm = neldermead_search(nm);
xopt = neldermead_get(nm,"-xopt");
fopt = neldermead_get(nm,"-fopt");
status = neldermead_get(nm,"-status");
funevals = neldermead_get(nm,"-funevals");
iterations = neldermead_get(nm,"-iterations");
mprintf("xopt=[%e %e]\n",xopt(1),xopt(2))
mprintf("fopt=%e\n",fopt)
mprintf("status=%s\n",status)
mprintf("funevals=%d\n",funevals)
mprintf("iterations=%d\n",iterations)
nm = neldermead_destroy(nm);