Issue with fminsearch function

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue with fminsearch function

Joel Lapin
Hello Octave

I am using fminsearch to optimize 2 parameters, which are fed to the function of interest as a 2 unit row vector -> [# #]. When I run fminsearch I get the following error message:

>> fminsearch('test', [0,1])
error: fun(0): subscripts must be either integers 1 to (2^63)-1 or logicals
error: called from
    fminsearch>nmsmax at line 275 column 8
    fminsearch at line 165 column 25

If I debug and go into the function, the issue appears at line 275

275: f(1) = dirn * fun (x, varargin{:});

the variable fun is literally the string 'test' and hence the indexing issue. Is there a bug in the fminsearch function?

Thank you in advance
Joel
 


Reply | Threaded
Open this post in threaded view
|

Re: Issue with fminsearch function

Doug Stewart-4


On Tue, Sep 10, 2019 at 5:23 PM Joel Lapin <[hidden email]> wrote:
Hello Octave

I am using fminsearch to optimize 2 parameters, which are fed to the function of interest as a 2 unit row vector -> [# #]. When I run fminsearch I get the following error message:

>> fminsearch('test', [0,1])
error: fun(0): subscripts must be either integers 1 to (2^63)-1 or logicals
error: called from
    fminsearch>nmsmax at line 275 column 8
    fminsearch at line 165 column 25

If I debug and go into the function, the issue appears at line 275

275: f(1) = dirn * fun (x, varargin{:});

the variable fun is literally the string 'test' and hence the indexing issue. Is there a bug in the fminsearch function?

Thank you in advance
Joel
 


did you make a variable called fun?



--
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

Re: Issue with fminsearch function

mmuetzel
In reply to this post by Joel Lapin
On Tue, 10 Sep 2019 14:15:16 -0400, Joel Lapin wrote

> Hello Octave
>
> I am using fminsearch to optimize 2 parameters, which are fed to the
> function of interest as a 2 unit row vector -> [# #]. When I run fminsearch
> I get the following error message:
>
> >> fminsearch('test', [0,1])
> error: fun(0): subscripts must be either integers 1 to (2^63)-1 or logicals
> error: called from
>     fminsearch>nmsmax at line 275 column 8
>     fminsearch at line 165 column 25
>
> If I debug and go into the function, the issue appears at line 275
>
> 275: f(1) = dirn * fun (x, varargin{:});
>
> the variable *fun* is literally the string 'test' and hence the indexing
> issue. Is there a bug in the fminsearch function?
>
> Thank you in advance
> Joel

Joel,

You are right. The Octave documentation isn't clear about it. But at least
for Matlab compatibility fminsearch should accept a string as the first input
argument. Using "feval" in the line you are citing would probably be better.
But there might be other places where we rely on the first argument being a
function handle.
Can you open a bug report about this on savannah [1], please?

For the time being, you could work around this by passing a function handle
as the first input argument:
fminsearch(@test, [0,1])

Markus

[1]: https://savannah.gnu.org/bugs/?group=octave


Reply | Threaded
Open this post in threaded view
|

Re: Issue with fminsearch function

mmuetzel
Am 11. September 2019 um 09:39 Uhr schrieb "Markus Mützel":
> You are right. The Octave documentation isn't clear about it. But at least
> for Matlab compatibility fminsearch should accept a string as the first input
> argument. Using "feval" in the line you are citing would probably be better.
> But there might be other places where we rely on the first argument being a
> function handle.
> Can you open a bug report about this on savannah [1], please?
>

As Joel wrote on private communication, he isn't able to sign up for savannah.
So I reported the bug here:
https://savannah.gnu.org/bugs/index.php?56885

Markus