[Scilab-users] Optim use and 'err' flag
paul.carrico at free.fr
paul.carrico at free.fr
Sat Jan 14 11:52:15 CET 2017
Hi Paul
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
CQFD :-)
Paul
Le 2017-01-13 22:15, paul.carrico at free.fr a écrit :
> Hi Paul
>
> I've been using the latest Scilab stable release on my working
> station; nevertheless you're right I get 12 when running the code on
> my laptop (same release but under Linux).
>
> Paul
>
> Le 2017-01-13 17:11, Paul Bignier a écrit :
>
> 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
>
> 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
_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170114/4ad363e2/attachment.htm>
More information about the users
mailing list