[scilab-Users] Report of potential problems with the nelder-mead series of functions

Sébastien Bihorel pomchip at free.fr
Fri Dec 11 12:58:38 CET 2009


Thank Michael,

A follow-up report concerning the optimsimplex_pfeffer and
optimsimplex_randbounds functions:
1- In optimsimplex_pfeffer function, could the following code

  //
  // Set 1st point
  //
  newobj.x ( 1 , 1:n ) = x0 (1,1:n)
  //
  // Set points #2 to #n+1
  //
  for j = 2 : newobj.n+1
    newobj.x ( j,1:n ) = x0 (1:n)
    if ( x0( j-1 ) == 0.0 ) then
      newobj.x ( j , j-1 ) = deltazero
    else
      newobj.x ( j , j-1 ) = newobj.x ( j , j-1 ) + deltausual * x0( j-1 )
    end
  end

be replaced by

  //
  // Set 1st point
  //
  newobj.x ( 1:newobj.nbve , : ) = x0 (1:n) .*. ones(newobj.nbve ,1);
  //
  // Set points #2 to #n+1
  //
  for j = 2 :newobj.nbve
    if ( x0( j-1 ) == 0.0 ) then
      newobj.x ( j , j-1 ) = deltazero
    else
      newobj.x ( j , j-1 ) = newobj.x ( j , j-1 ) + deltausual * x0( j-1 )
    end
  end

2- in optimsimplex_randbounds, there is no check that boundsmin and
boundsmax have at least n elements before those calls are made
    bminmat = boundsmin( 1,1:n ) .*. ones(nbve-1,1);
    bmaxmat = boundsmax( 1,1:n ) .*. ones(nbve-1,1);

also, should the line

newobj$nbve <- n + 1

not be

newobj$nbve <- nbve

?

Sebastien

On Thu, Dec 10, 2009 at 12:02 PM, Michaël Baudin
<michael.baudin at scilab.org>wrote:

> Hi,
>
> I agree on both points : I will commit a bug fix in branch 5.2 tomorrow.
>
> Best regards,
>
> Michaël
>
> Sébastien Bihorel a écrit :
>
>  Hi,
>>
>> I was reading through the code of the fminsearch function and its wealth
>> of related functions, and was wondering if there could be a problem with the
>> optimsimplex.axes function. At this point, I honestly don't know what it is
>> doing but I think there might be something wrong with the code:
>> 1- xlen1 is defined but never used. The check that is directly following
>> its definition is probably supposed to use it but doesn't
>>    xlen1 = size(len,1)
>>    if size(x0,1)<>1 then
>>      errmsg = msprintf(gettext("%s: The len vector is expected to be a row
>> matrix, but current shape is %d x
>> %d"),"optimsimplex_axes",size(len,1),size(len,2));
>>      error(errmsg);
>>    end
>>
>> 2- nothing seems to prevent this call to crash, the dimensions of xlen and
>> the matrix newobj.x(,) are not cross-checked
>>  newobj.x ( 2:nv , : ) = newobj.x ( 2:nv , : ) + diag(xlen);
>>
>> HIH
>>
>> Sebastien
>>
>
>
> --
> 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
>
>
>


On Fri, Dec 11, 2009 at 6:12 AM, Michaël Baudin
<michael.baudin at scilab.org>wrote:

> Hi,
>
> I created a bug report :
> http://bugzilla.scilab.org/show_bug.cgi?id=5604
> and fixed the source code in v5.2 branch :
>
> http://gitweb.priv.scilab.org/?p=scilab.git;a=commitdiff;h=8e6a14e2189dde039afc67aaeef3e18aeb0cf869
>
> Before, we had :
> -->function y = rosenbrock (x)
> -->  y = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
> -->endfunction
> -->newobj = optimsimplex_new ( "axes" , [1 2] , rosenbrock , [1 2 3] );
> !--error 8
> Inconsistent addition.
> at line      39 of function optimsimplex_axes called by : at line      34
> of function optimsimplex_new called by : newobj = optimsimplex_new ( "axes"
> , [1 2] , rosenbrock , [1 2 3] );
>
> Now, you get the message :
> optimsimplex_axes: The len vector is not consistent with the x0 point.
> Current shape of x0 is 1 x 2 while current shape of len is 1 x 3.
> which is much clearer.
> By the way, I improved the error messages of other scripts.
> Thank you for reporting that problem.
>
>
> Best regards,
>
> Michaël
>
> Sébastien Bihorel a écrit :
>
>> Hi,
>>
>>
>> I was reading through the code of the fminsearch function and its wealth
>> of related functions, and was wondering if there could be a problem with the
>> optimsimplex.axes function. At this point, I honestly don't know what it is
>> doing but I think there might be something wrong with the code:
>> 1- xlen1 is defined but never used. The check that is directly following
>> its definition is probably supposed to use it but doesn't
>>    xlen1 = size(len,1)
>>    if size(x0,1)<>1 then
>>      errmsg = msprintf(gettext("%s: The len vector is expected to be a row
>> matrix, but current shape is %d x
>> %d"),"optimsimplex_axes",size(len,1),size(len,2));
>>      error(errmsg);
>>    end
>>
>> 2- nothing seems to prevent this call to crash, the dimensions of xlen and
>> the matrix newobj.x(,) are not cross-checked
>>  newobj.x ( 2:nv , : ) = newobj.x ( 2:nv , : ) + diag(xlen);
>>
>> HIH
>>
>> Sebastien
>>
>
>
> --
> 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/20091211/f0857a14/attachment.htm>


More information about the users mailing list