bugGNU Octave - Bugs: bug #41915, fminsearch: problem with anonymous...

 
 

bug #41915: fminsearch: problem with anonymous function and options

Submitter:  Hartmut <hardy>
Submitted:  Thu 20 Mar 2014 09:04:36 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 3.8.1 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 29 Mar 2014 06:50:14 PM UTC, comment #6: 

I checked in a changeset that changes optimget() and thereby fixes the example in this bug report.  The fix was done on the development branch (http://hg.savannah.gnu.org/hgweb/octave/rev/8d4d78285c8e).  In order to see the fix you will need to wait until the 4.2 release, which could be a very long time, or simply grab the optimset.m and optimget.m files from Mercurial (there is a web interface at http://hg.savannah.gnu.org/hgweb/octave/).

Rik <rik5>
Group administrator
Wed 26 Mar 2014 08:50:53 PM UTC, comment #5: 

Thanks for the testing.  I can see how to fix this now, but I probably can't get to it until the weekend.

Rik <rik5>
Group administrator
Wed 26 Mar 2014 08:25:45 PM UTC, comment #4: 

You were right, Matlab does return the value 100 (which is obviously the same as 1e2) for the optimget commmand you wrote.

By the way, I have also notice another difference between Matlab and Octave. The command

options = optimset('TolX',1e-6)

does produce different results:

  • Matlab returns a big struct with a lot of empty fields, and only one field with content, the TolX field. I have attached textfile that shows thte Matlab result.


  • Octave returns a struct with onyl one field, the TolX field.


I dont' know if this difference to Matlab has anything to do with the topic of this bug.

(file #31051)

Hartmut <hardy>
Mon 24 Mar 2014 10:42:52 PM UTC, comment #3: 

This is kind of what I expected was happening.  What does Matlab do for this piece of code?


options = optimset ();
tst = optimget (options, 'TolX', 1e2)


I think it will return 1e2, while Octave returns [].

If that is the case, this is pretty easy to fix inside optimget.

Rik <rik5>
Group administrator
Mon 24 Mar 2014 07:48:48 PM UTC, comment #2: 

I have checked what Matlab and Octave give as results of

options = optimset


You find the detailed results in the two attached text files. (Matlab version is 7.11.0 which is R2010b, Octave version is 3.8.1)

BOTH results are a struct of several named fields, with all the field values being empty. Matlab has some more fields, but I assume that the Octave version of optimset will generate all necessary fields for the Octave version of fminsearch.

So the bottom line might be, that fminsearch in Octave should be able to deal with option structs that contain empty values.

(file #31028, file #31029)

Hartmut <hardy>
Fri 21 Mar 2014 04:29:40 AM UTC, comment #1: 

What is the result of


options = optimset


in Matlab?

I think the problem is that the above command in Octave is creating a structure where every named field, like 'TolX', has an empty value.

Rik <rik5>
Group administrator
Thu 20 Mar 2014 09:04:36 PM UTC, original submission:  

Here is an example that shows the behavior:

  • myfun.m contains:


function f = myfun(x,a)
f = x(1)^2 + a*x(2)^2;


  • The demo script is:


param = 1.5;
options = optimset;
start = [1,3];
result = fminsearch (@(x) myfun(x, param),start,options)


Octave throws an error message: "error: parse_options: A(I) = X: X must have the same size as I".

In Matlab the very same script returns a useful result. Since I haven't found where this usage of fminsearch violates its documented behavior, I've reported this as "incorrect result" for now, but maybe I'm wrong.

Note: If you leave out the options, then the script runs totally fine in Octave (as well as in Matlab), but obviously without your intended options:


param = 1.5;
options = optimset;
start = [1,3];
result = fminsearch (@(x) myfun(x, param),start)


Hartmut <hardy>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #31051:  optimset_matlab.txt added by hardy (2KiB - text/plain)
file #31028:  options_Matlab.txt added by hardy (2KiB - text/plain)
file #31029:  options_Octave.txt added by hardy (404B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by hardy (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-03-29 rik5 StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2014-03-26 hardy Attached File- Added optimset_matlab.txt, #31051
    2014-03-24 rik5 StatusNone In Progress
    2014-03-24 hardy Attached File- Added options_Matlab.txt, #31028
        Attached File- Added options_Octave.txt, #31029

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code