bugGNU Octave - Bugs: bug #63925, 'lsqnonlin' ceases to converge...

 
 

bug #63925: 'lsqnonlin' ceases to converge from a small change(Matlab - OK)

Submitter:  None
Submitted:  Tue 14 Mar 2023 03:18:52 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Need Info Assigned to:  None
Originator Name:  Leo Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * 8.1.0
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 22 Mar 2023 08:42:44 AM UTC, comment #5: 

I realized that the multiplication signs disappeared in the code without tags. Add m files.

(file #54519, file #54520)

Anonymous
Tue 21 Mar 2023 03:07:05 PM UTC, comment #4: 

Could the original bug reporter re-post the minimum example using verbatim tags (see https://savannah.gnu.org/markup-test.php) or upload the code as an m-file to this report so we can see the problem clearly?

Rik <rik5>
Group administrator
Wed 15 Mar 2023 06:38:45 PM UTC, comment #3: 

@OP: there is a verbatim tag available. That is useful to quote code, avoiding the multiplication operator to be interpreted as boldface in this post.

Also, this seems to be a linear problem, with linear constraints, for which octave's glpk is suitable.

A.R. Burgers <arb>
Wed 15 Mar 2023 06:25:12 AM UTC, comment #2: 

Yes i used "pkg load optim"

Anonymous
Tue 14 Mar 2023 08:08:22 PM UTC, comment #1: 
Anonymous
Tue 14 Mar 2023 03:18:52 PM UTC, original submission:  

tryed on 7.3.0, both OpenBLAS and Reference BLAS

# did't work (working only in Mathlab online):

fun = @(x)[ x(5) 0.1 +  x(4) 0.25 +  x(3) 0.5 +  x(2) 0.25 +  x(1) * 0.1 - 0.3;
x(6) 0.1 +  x(5) 0.25 +  x(4) 0.5 +  x(3) 0.25 +  x(2) * 0.1 - 0.62500001;
x(7) 0.1 +  x(6) 0.25 +  x(5) 0.5 +  x(4) 0.25 +  x(3) * 0.1 - 0.500000025;
x(8) 0.1 +  x(7) 0.25 +  x(6) 0.5 +  x(5) 0.25 +  x(4) * 0.1 - 0.22500005;
x(9) 0.1 +  x(8) 0.25 +  x(7) 0.5 +  x(6) 0.25 +  x(5) * 0.1 - 0.050000025000000003;
x(10) 0.1 +  x(9) 0.25 +  x(8) 0.5 +  x(7) 0.25 +  x(6) * 0.1 - 1e-08];
options = optimset("Display", "iter","FinDiffType" ,"central","MaxIter", 20000, "MaxFunEvals", 40000, "TolFun", 1e-39, "TolX", 1e-39);
x0 = [0.5,0.5,0.5,0.5,0.5,5e-08,2e-08,1e-08,2e-08,5e-08];
lb = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0];
ub = [2.9999999999999996,1.2,0.6,1.2,0.50000025,1e-07,4e-08,2e-08,4e-08,1e-07];
[x,val] = lsqnonlin(fun, x0, lb, ub, options);

# Ideal estimated result
#   [0.0, 0.0, 0.0, 1.0, 0.5, 0.0000001, 0.0, 0.0, 0.0, 0.0]
# Mathlab online result, perfect
#   x: [0, 0, 0, 1.0000, 0.5000, 1.0000e-07, 2.2301e-17, 0, 0, 0]
#   val: 3.112467704292398e-33
# Octave result, to bad
#   x     [6.1062e-16, 0.32759, 0.42248, 0.46753, 0.48734, 1e-07, 5.7973e-16, 1.099e-16, 4e-08, 2.4127e-15
#   val   0.055000


# working good (both in Octave and Mathlab online):

fun = @(x)[ x(5) 0.1 +  x(4) 0.25 +  x(3) 0.5 +  x(2) 0.25 +  x(1) * 0.1 - 0.3;
x(6) 0.1 +  x(5) 0.25 +  x(4) 0.5 +  x(3) 0.25 +  x(2) * 0.1 - 0.625;
x(7) 0.1 +  x(6) 0.25 +  x(5) 0.5 +  x(4) 0.25 +  x(3) * 0.1 - 0.5;
x(8) 0.1 +  x(7) 0.25 +  x(6) 0.5 +  x(5) 0.25 +  x(4) * 0.1 - 0.225;
x(9) 0.1 +  x(8) 0.25 +  x(7) 0.5 +  x(6) 0.25 +  x(5) * 0.1 - 0.05;
x(10) 0.1 +  x(9) 0.25 +  x(8) 0.5 +  x(7) 0.25 +  x(6) * 0.1 - 0.0];
options = optimset("Display", "iter","FinDiffType" ,"central","MaxIter", 20000, "MaxFunEvals", 40000, "TolFun", 1e-39, "TolX", 1e-39);
x0 = [0.5,0.5,0.5,0.5,0.5,0.0,0.0,0.0,0.0,0.0];
lb = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0];
ub = [2.9999999999999996,1.2,0.6,1.2,0.5,0.0,0.0,0.0,0.0,0.0];
[x,val] = lsqnonlin(fun, x0, lb, ub, options);

# Ideal estimated result
#   [0.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0]
# Mathlab online result, perfect
#   x: [0, 0, 0, 1, 0.5000, 0, 0, 0, 0, 0]
#   val: 0
# Octave result, good
# x     [1.3332e-16, 1.0417e-17, 2.189e-12, 1, 0.5, 0, 0, 0, 0, 0]
# val   6.782908519975903e-25


looks like some kind of crutch in the solver

Can i do somesthing with it?
(potentially ready to participate in the search for a problem if there is introductory information on the code stack and localization)

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #54519:  bug_63925_converged_in_Octave.m added by None (921B - application/octet-stream)
file #54520:  bug_63925_not_converged_in_Octave.m added by None (975B - application/octet-stream)

 

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 arb (Posted a comment)
  • -email is unavailable- added by None (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-03-22 None Attached File- Added bug_63925_converged_in_Octave.m, #54519
        Attached File- Added bug_63925_not_converged_in_Octave.m, #54520
    2023-03-21 rik5 StatusNone Need Info
        Summary'lsqnonlin' ceases to converge from a small change(Mathlab - OK) 'lsqnonlin' ceases to converge from a small change(Matlab - OK)

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code