<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">Hi Paul</div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"> </div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">I found why I had err=3: I was "playing" with the step value of numderivative and I sent the last trial; neveryheless if you remove it of use a low value such as 0.01 instead of 0.1, the err value becomes 3</div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"> </div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">CQFD :-)</div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"> </div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">Paul</div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"> </div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"> </div>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">Le 2017-01-13 22:15, <a href="mailto:paul.carrico@free.fr">paul.carrico@free.fr</a> a écrit :
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">Hi Paul <br /> <br /> I've been using the latest Scilab stable release on my working<br /> station; nevertheless you're right I get 12 when running the code on<br /> my laptop (same release but under Linux). <br /> <br /> Paul <br /> <br /> Le 2017-01-13 17:11, Paul Bignier a écrit : <br /> <br />
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">Hello Paul,<br /> <br /> Running your script gives me "err=12", which is not documented but I<br /> don't get how you got 3?<br /> <br /> I see though that you reached 'evals' & 'iters', perhaps optim<br /> wanted<br /> to continue but was capped by those.<br /> <br /> Feel free to use the format [1 [1]] function to get more on-screen<br /> precision to your values.<br /> <br /> I will surely commit something soon in order to fix the "12" flag.<br /> <br /> Have a good evening,<br /> <br /> Paul<br /> <br /> On 01/13/2017 02:39 PM, <a href="mailto:paul.carrico@free.fr">paul.carrico@free.fr</a> wrote:<br /> <br />
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">Hi all<br /> <br /> I'm trying to improve how to use Optim in Scilab, so I'm still<br /> using the basic Rosembrock function; in the example hereafter, one<br /> can see that Optim goes back the Error flag to 3 and I do not<br /> understand why?<br /> <br /> The goal is to be able to check all the values of this flag in<br /> order<br /> to validate the result ; while the values are the optimized ones,<br /> the calculation indicates that the optimization fails …<br /> <br /> I'm a bit loss … so any feedback will be appreciated<br /> <br /> Thanks<br /> <br /> Paul</blockquote>
</blockquote>
###################################################################################
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><br /> <br />
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">In my understanding:<br /> -    err = 9 : everything went well … ok<br /> <br /> -    err = 3 : Optimization stops because of too small variations<br /> for x<br /> -    err=1 : Norm of projected gradient lower than …<br /> -    err=2 : At last iteration f decreases by less than …<br /> -    err=4 : Optim stops: maximum number of calls to f is reached<br /> ==> increase nocf<br /> -    err=5 : Optim stops: maximum number of iterations is reached.<br /> ==> increase niter<br /> -    err=6 : Optim stops: too small variations in gradient<br /> direction.<br /> -    err=7 : Stop during calculation of descent direction.<br /> -    err=8 : Stop during calculation of estimated hessian.<br /> -    err=10 : End of optimization (linear search fails).<br /> <br /> // Rosembrock function<br /> function f=rosembrock(x)<br /> f = ( 1 - x(1))^2 + 100*( x(2)-x(1)^2 )^2;<br /> endfunction<br /> <br /> // Cost function<br /> function [f, g, ind]=cost(x, ind)<br /> f = rosembrock(x);<br /> //        g = derivative(rosembrock, x.',order = 4);<br /> //            g = numderivative(rosembrock, x.',order = 4);<br /> g = numderivative(rosembrock, x.',0.1, order = 4);<br /> endfunction<br /> <br /> initial_parameters = [10 100]<br /> lower_bounds = [0 0];<br /> upper_bounds = [1000 1000];<br /> nocf = 100000;      // number of call of f<br /> niter = 100000;    // number of iterations<br /> [fopt, xopt, gopt, work, iters, evals, err] =</blockquote>
</blockquote>
optim(cost,'b',lower_bounds,upper_bounds,initial_parameters,'qn','ar',nocf,niter);
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><br /> <br />
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">xopt<br /> fopt<br /> iters<br /> evals<br /> err<br /> _______________________________________________<br /> users mailing list<br /> <a href="mailto:users@lists.scilab.org">users@lists.scilab.org</a><br /> <a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank" rel="noreferrer">http://lists.scilab.org/mailman/listinfo/users</a></blockquote>
<br /> --<br /> Paul BIGNIER<br /> Development engineer<br /> -----------------------------------------------------------<br /> Scilab Enterprises<br /> 143bis rue Yves Le Coz - 78000 Versailles, France<br /> Phone: +33.1.80.77.04.68<br /> <a href="http://www.scilab-enterprises.com" target="_blank" rel="noreferrer">http://www.scilab-enterprises.com</a><br /> <br /> Links:<br /> ------<br /> [1] <a href="https://help.scilab.org/docs/6.0.0/en_US/format.html" target="_blank" rel="noreferrer">https://help.scilab.org/docs/6.0.0/en_US/format.html</a><br /> _______________________________________________<br /> users mailing list<br /> <a href="mailto:users@lists.scilab.org">users@lists.scilab.org</a><br /> <a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank" rel="noreferrer">http://lists.scilab.org/mailman/listinfo/users</a></blockquote>
 <br /> <br /> Links:<br /> ------<br /> [1] <a href="https://help.scilab.org/docs/6.0.0/en_US/format.html" target="_blank" rel="noreferrer">https://help.scilab.org/docs/6.0.0/en_US/format.html</a><br /> _______________________________________________<br /> users mailing list<br /> <a href="mailto:users@lists.scilab.org">users@lists.scilab.org</a><br /> <a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank" rel="noreferrer">http://lists.scilab.org/mailman/listinfo/users</a></blockquote>
</div>
</body></html>