octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: small bug in fminsearch


From: Andrea Latina
Subject: Re: small bug in fminsearch
Date: Thu, 8 Aug 2019 12:25:11 +0200

Hi Kai,

nice to read you. Yes, I called fminsearch with an extra parameter. fminsearch correctly called the function throughput the full optimisation, but gave an error when evaluating the function for the second return value.

Thank you for the hint on using the anonymous functions!. It looks indeed more elegant.

Best wishes,
Andrea

On Thu, 8 Aug 2019 at 03:39, Kai Torben Ohlhus <address@hidden> wrote:
On 8/8/19 12:10 AM, Andrea Latina wrote:
> Hello Olaf (as maintainer of the 'optim' package), hello everyone,
>
> I've found a small bug in fminsearch.m in octave 5.1.0 :
>
> line 168 should be
>     fval = feval (fun, x, varargin{:});
>
> and not
>     fval = feval (fun, x);
>
> Best,
> Andrea


Dear Andrea,

Thank you for the report.  Do you want to enable the following calling
scheme?

  f = @(x,a) x.^2 + a;
  a = 3;
  x0 = 1;
  [x, fval] = fminsearch (f, x0, [], a)

This behavior is no longer documented by Matlab [1] (but still works in
R2019a). The Mathworks encourages to use anonymous functions instead:

  f = @(x,a) x.^2 + a;
  a = 3;
  fun = @(x)f(x,a);
  x0 = 1;
  [x, fval] = fminsearch (fun, x0)

This works perfectly in both Octave and Matlab.  In bug #55742 [2] it
was recently decided not to support undocumented Matlab features, as
they are more likely to change quietly and are difficult to support and
test.

With best wishes,

Kai

[1] https://www.mathworks.com/help/matlab/ref/fminsearch.html
[2] https://savannah.gnu.org/bugs/?55742


reply via email to

[Prev in Thread] Current Thread [Next in Thread]