<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<p>To complete my previous answer, the error arose from the built-in
line search algorithm (err>10 means different flavors of it
failing). In your case, it is pointing to a "too small deltaT", so
yes it looks like your algorithm is converging but it has trouble
finishing.</p>
<p>You can get more info by using "imp=3" in your call to optim (as
documented). If you are using a nightly build then use "iprint=3"
(the online doc hasn't been updated yet).</p>
<p>Best regards,</p>
<p>Paul</p>
<br>
<div class="moz-cite-prefix">On 01/13/2017 05:11 PM, Paul Bignier
wrote:<br>
</div>
<blockquote
cite="mid:e44eb5ac-6536-2fc3-9e55-7560a145d9a0@scilab-enterprises.com"
type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<p><br>
</p>
<p>Hello Paul,</p>
<p>Running your script gives me "err=12", which is not documented
but I don't get how you got 3?</p>
<p>I see though that you reached 'evals' & 'iters', perhaps
optim wanted to continue but was capped by those.</p>
<p>Feel free to use the <a moz-do-not-send="true"
href="https://help.scilab.org/docs/6.0.0/en_US/format.html">format</a>
function to get more on-screen precision to your values.</p>
<p>I will surely commit something soon in order to fix the "12"
flag.</p>
<p>Have a good evening,</p>
<p>Paul<br>
</p>
<br>
<div class="moz-cite-prefix">On 01/13/2017 02:39 PM, <a
moz-do-not-send="true" class="moz-txt-link-abbreviated"
href="mailto:paul.carrico@free.fr">paul.carrico@free.fr</a>
wrote:<br>
</div>
<blockquote cite="mid:9e5678541fe2780181db9bcb00246d16@free.fr"
type="cite">Hi all <br>
<br>
I’m trying to improve how to use Optim in Scilab, so I’m still
using the basic Rosembrock function; in the example hereafter,
one can see that Optim goes back the Error flag to 3 and I do
not understand why? <br>
<br>
The goal is to be able to check all the values of this flag in
order to validate the result ; while the values are the
optimized ones, 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 <br>
<br>
###################################################################################
<br>
In my understanding: <br>
- err = 9 : everything went well … ok <br>
<br>
- err = 3 : Optimization stops because of too small
variations 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 ==> increase nocf <br>
- err=5 : Optim stops: maximum number of iterations is
reached. ==> increase niter <br>
- err=6 : Optim stops: too small variations in gradient
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>
<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] =
optim(cost,'b',lower_bounds,upper_bounds,initial_parameters,'qn','ar',nocf,niter);<br>
xopt <br>
fopt <br>
iters <br>
evals <br>
err <br>
_______________________________________________ <br>
users mailing list <br>
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<br>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
<br>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Paul BIGNIER
Development engineer
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Phone: +33.1.80.77.04.68
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.scilab-enterprises.com">http://www.scilab-enterprises.com</a></pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Paul BIGNIER
Development engineer
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Phone: +33.1.80.77.04.68
<a class="moz-txt-link-freetext" href="http://www.scilab-enterprises.com">http://www.scilab-enterprises.com</a></pre>
</body>
</html>