[Scilab-users] Optim use and 'err' flag

paul.carrico at free.fr paul.carrico at free.fr
Fri Jan 13 22:22:27 CET 2017


Paul, 

When using imp=3, I can see that 'iters' returns in fact the value of
niter (ditto for evals and nocf): am I right ? 

[fopt, xopt, gopt, work, iters, evals, err] =
optim(cost,'b',lower_bounds,upper_bounds,initial_parameters,'qn','ar',nocf,niter,imp=3);

(thanks for the support) 

Paul 

Le 2017-01-13 18:06, Paul Bignier a écrit : 

> 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. 
> 
> 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). 
> 
> Best regards, 
> 
> Paul 
> On 01/13/2017 05:11 PM, Paul Bignier wrote:
> 
> Hello Paul,
> 
> Running your script gives me "err=12", which is not documented but I
> don't get how you got 3?
> 
> I see though that you reached 'evals' & 'iters', perhaps optim
> wanted to continue but was capped by those.
> 
> Feel free to use the format [1 [1]] function to get more on-screen
> precision to your values.
> 
> I will surely commit something soon in order to fix the "12" flag.
> 
> Have a good evening,
> 
> Paul
> 
> On 01/13/2017 02:39 PM, paul.carrico at free.fr wrote:
> 
> Hi all
> 
> 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?
> 
> 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 …
> 
> I'm a bit loss … so any feedback will be appreciated
> 
> Thanks
> 
> Paul

###################################################################################


>> In my understanding:
>> -    err = 9 : everything went well … ok
>> 
>> -    err = 3 : Optimization stops because of too small variations
>> for x
>> -    err=1 : Norm of projected gradient lower than …
>> -    err=2 : At last iteration f decreases by less than …
>> -    err=4 : Optim stops: maximum number of calls to f is reached
>> ==> increase nocf
>> -    err=5 : Optim stops: maximum number of iterations is reached.
>> ==> increase niter
>> -    err=6 : Optim stops: too small variations in gradient
>> direction.
>> -    err=7 : Stop during calculation of descent direction.
>> -    err=8 : Stop during calculation of estimated hessian.
>> -    err=10 : End of optimization (linear search fails).
>> 
>> // Rosembrock function
>> function f=rosembrock(x)
>> f = ( 1 - x(1))^2 + 100*( x(2)-x(1)^2 )^2;
>> endfunction
>> 
>> // Cost function
>> function [f, g, ind]=cost(x, ind)
>> f = rosembrock(x);
>> //        g = derivative(rosembrock, x.',order = 4);
>> //            g = numderivative(rosembrock, x.',order = 4);
>> g = numderivative(rosembrock, x.',0.1, order = 4);
>> endfunction
>> 
>> initial_parameters = [10 100]
>> lower_bounds = [0 0];
>> upper_bounds = [1000 1000];
>> nocf = 100000;      // number of call of f
>> niter = 100000;    // number of iterations
>> [fopt, xopt, gopt, work, iters, evals, err] =

optim(cost,'b',lower_bounds,upper_bounds,initial_parameters,'qn','ar',nocf,niter);


>> xopt
>> fopt
>> iters
>> evals
>> err
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
> 
> --
> Paul BIGNIER
> Development engineer
> -----------------------------------------------------------
> Scilab Enterprises
> 143bis rue Yves Le Coz - 78000 Versailles, France
> Phone: +33.1.80.77.04.68
> http://www.scilab-enterprises.com
> 
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-- 
Paul BIGNIER
Development engineer
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Phone: +33.1.80.77.04.68
http://www.scilab-enterprises.com

Links:
------
[1] https://help.scilab.org/docs/6.0.0/en_US/format.html
_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users 

Links:
------
[1] https://help.scilab.org/docs/6.0.0/en_US/format.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170113/b816e458/attachment.htm>


More information about the users mailing list