[scilab-Users] false results in Rosenbrock equation

Michaël Baudin michael.baudin at scilab.org
Tue Jan 18 09:19:44 CET 2011


Hi Paul,

The status of the optimization is not good when the parameters are left 
to the default values :

-->neldermead_get(nm,"-status")
  ans =
maxfuneval

This means that the maximum number of function evaluations where reached 
before the convergence was attained. All we need to do is to increase 
the maximum number of function evaluations. In order to get even closer 
to the optimum, we must also increase the number of iterations.

nm = neldermead_configure(nm,"-maxfunevals",200);
nm = neldermead_configure(nm,"-maxiter",200);

Once done, I get :

-->xopt = neldermead_get(nm,"-xopt")
  xopt  =
     1.0035954
     1.0073491

This is quite a difficult case for Nelder-Mead's algorithm. The simplex 
has to go through a long curved valley before reaching the zone where 
the function begins to behave as a quadratic function.

Rosenbrock's function has only one global minimum, at x=[1,1]. The point 
x=[-1,1] is not a minimum.

This is easy to check with Scilab. First, let us define the function.

     function [f,G,H] = rosenbrock(x)
         f = 100*(x(2) - x(1)^2)^2 + (1 - x(1))^2;

         // Calculation of the gradient G vector
         G(1) = -400*x(1)*(x(2) - x(1)^2) - 2*(1 - x(1));
         G(2) = 200*(x(2) - x(1)^2);

         // Calculation of the Hessian matrix
         H(1,1) = -400*x(2) + 1200*x(1)^2 + 2;
         H(1,2) = -400*x(1);
         H(2,1) = -400*x(1);
         H(2,2) = 200;
     endfunction

We get at x= [1,1] :

-->[f,G,H] = rosenbrock([1,1])
  H  =
     802.  - 400.
   - 400.    200.
  G  =
     0.
     0.
  f  =
     0.

This means that the gradient is zero, implying that the first order 
conditions for unconstrained optimality are satisfied. Moreover, the 
eigenvalues of the Hessian matrix are positive, as shown below :

-->spec(H)
  ans  =
     0.3993608
     1001.6006

This implies that the local curvature of the Rosenbrock function is 
positive : x* is indeed a minimum.

Now, at x=[-1,1], we get :

-->[f,G,H] = rosenbrock([-1,1])
  H  =
     802.    400.
     400.    200.
  G  =
   - 4.
     0.
  f  =
     4.

The gradient is nonzero, which means that the first order optimality 
conditions are not satisfied at x=[-1,1]. Rosenbrock's function is a sum 
of squares.

Best regards,

Michaël


Le 17/01/2011 11:18, Carrico, Paul a écrit :
> Dear all
> In the Rosenbrock equation it is well known the 2 minima are (1,1) and 
> (-1,1) ; in the attached where I want to test several optimization 
> macros (and basic &particular functions) I've a different result as 
> descibed herebellow : is there a mistake in the input file or does 
> something go wrong ?
> Please note the functions inputs are as general as possible to be used 
> with the different macros (fminsearch, optim and so on)
> Paul
> #################################################################"
>     - X1 optimized = 0.229978
>     - X2 optimized = 0.0240434
> --------------------------------------------------------------------------------
>
>
> Le présent mail et ses pièces jointes sont confidentiels et destinés à la personne ou aux personnes visée(s) ci-dessus. Si vous avez reçu cet e-mail par erreur, veuillez contacter immédiatement l'expéditeur et effacer le message de votre système. Toute divulgation, copie ou distribution de cet e-mail est strictement interdite.
>
> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error, please contact the sender and delete the email from your system. If you are not the named addressee you should not disseminate, distribute or copy this email.
>
>


-- 
Michaël Baudin
Ingénieur de développement
michael.baudin at scilab.org
-------------------------
Consortium Scilab - Digiteo
Domaine de Voluceau - Rocquencourt
B.P. 105 - 78153 Le Chesnay Cedex
Tel. : 01 39 63 56 87 - Fax : 01 39 63 55 94


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20110118/7d84166c/attachment.htm>


More information about the users mailing list