bugGNU Octave - Bugs: bug #61801, [octave forge] (optim) lsqnonlin...


bug #61801: [octave forge] (optim) lsqnonlin doesn't work under Octave 7.0.90

Submitted by:  None
Submitted on:  Wed 12 Jan 2022 11:07:46 AM UTC  
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Confirmed Assigned to:  None
Originator Name:  MSpo Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  7.0.90
Operating System:  Any

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Mon 17 Jan 2022 03:26:06 PM UTC, comment #3: 

Note that fmincon is affected by the same issue:

octave:1> pkg load optim
octave:2> test fmincon
***** test
 ## equality constraint
 objective_function = @ (p) p(1)^2 + p(2)^2;
 pin = [-2; 5];
 constraint_function = @ (p) - (p(1)^2 + 1 - p(2));
 [p, objf, cvg, outp] = fmincon (objective_function, pin, [], [], [], [], [], [], @ (p) {[], constraint_function(p)}{:}, optimset ("Algorithm", "lm_feasible"));
 assert (p, [0; 1], 1e-6)
!!!!! test failed
: function called with too many inputs

Sébastien Villemot <svillemot>
Wed 12 Jan 2022 01:54:49 PM UTC, comment #2: 

The issue seems to be that __dfdp__ is defined with a fixed number of 3 input arguments, but handles stuff differently depending on the actual value of nargin. However, with Octave 7.0.90 it must be 3 arguments or the error is thrown.

Wed 12 Jan 2022 12:42:38 PM UTC, comment #1: 

I initially thought this was a broader issue with `varargin` in anonymous functions. But that seems to be working as it should.

As far as I can tell, `func` in line 304 of _dfdp_.m corresponds to the first argument of `lsqnonlin`. It does indeed take only one argument. But `func` is called with two arguments in that line.

CC'ing package maintainer.

Markus Mützel <mmuetzel>
Project Member
Wed 12 Jan 2022 11:07:46 AM UTC, original submission:  

This minimal example works under Octave 6.4.0 but throws an error in Octave 7.0.90 (plus, there are a couple of warnings when loading the optim package):

pkg load optim

x = (0:0.01:10).';
y = @(p) p(1) + p(2)*sin(2*pi*p(3)*x);

p0 = [0.3 0.5 0.2];
y0 = y([0.37 0.63 0.21]) + (rand(size(x))-0.5);

p_fit = lsqnonlin(@(p) y(p) - y0,p0);

I get this error:

error: : function called with too many inputs
error: called from
    __dfdp__ at line 304 column 15
    __nonlin_residmin__>@<anonymous> at line 329 column 26
    __jacobian_constants__>@<anonymous> at line 121 column 11
    __lm_svd__ at line 196 column 9
    __nonlin_residmin__ at line 452 column 25
    nonlin_residmin at line 98 column 25
    lsqnonlin at line 264 column 21
    optim_bug at line 9 column 7

It seems to boil down to line 316 in \_\_nonlin_residmin\_\_

f.f = @ (varargin) f.f (varargin{:}) - obs;

which doesn’t seem to be allowed anymore.



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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by svillemot (Posted a comment)
  • -email is unavailable- added by svillemot
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by mmuetzel
  • -email is unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-01-17 svillemot Carbon-Copy- => Added svillemot
    2022-01-12 mmuetzel StatusNone => Confirmed
        Operating SystemMicrosoft Windows => Any
        Summarylsqnonlin from optim package doesn't work under Octave 7.0.90 => [octave forge] (optim) lsqnonlin doesn't work under Octave 7.0.90
        Carbon-Copy- => Added i7tiol

    Back to the top

    Powered by Savane 3.7