bugGNU Octave - Bugs: bug #36015, unexpected sqp error


bug #36015: unexpected sqp error

Submitter:  John W. Eaton <jwe>
Submitted:  Tue 27 Mar 2012 03:28:12 PM UTC
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  lachlan
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


( Jump to the original submission )

Mon 27 Mar 2017 09:57:12 PM UTC, comment #7: 

No response.  I believe this now works in dev withhout patching.  Closing report.

Rik <rik5>
Project Administrator
Mon 13 Mar 2017 05:58:26 AM UTC, comment #6: 

@Ben: Could you re-test your example from comment #4 on a current tip?  It seems to work for me without any modification.

I think the original demonstration code from an e-mail to jwe contains an error.  The qp function is invoked as


But the documentation is

-- [X, OBJ, INFO, LAMBDA] = qp (X0, H)
-- [X, OBJ, INFO, LAMBDA] = qp (X0, H, Q)
-- [X, OBJ, INFO, LAMBDA] = qp (X0, H, Q, A, B)
-- [X, OBJ, INFO, LAMBDA] = qp (X0, H, Q, A, B, LB, UB)
-- [X, OBJ, INFO, LAMBDA] = qp (X0, H, Q, A, B, LB, UB, A_LB, A_IN, A_UB)

I don't see a 6-input calling form which makes me think the example itself is bad rather than Octave.

Rik <rik5>
Project Administrator
Mon 13 Feb 2017 01:04:09 AM UTC, comment #5: 

I haven't studied how qp() works and don't know if this is a proper solution, but it allows my example and jwe's to work.

(file #39748)

Ben Abbott <bpabbott>
Project Member
Sun 12 Feb 2017 08:39:55 PM UTC, comment #4: 

I came across a bug introduced by Lacklan's changeset.

I'm attaching a simple script that triggers the error (something to do with the values of the upper bounds requiring an equality constraint).

I'm not familiar with glpk.m, qp.m, and sqp.m, but reversing the qp.m portion of Lacklan's changeset fixed the problem for me.

diff --git a/scripts/optimization/qp.m b/scripts/optimization/qp.m
--- a/scripts/optimization/qp.m
+++ b/scripts/optimization/qp.m
@@ -373,8 +373,8 @@
             Atmp = [Ain, gamma];
             btmp = bin;
-          ctmp = [zeros(n-n_eq, 1); ones(n_in, 1)];
-          lb = [-Inf(n-n_eq,1); zeros(n_in,1)];
+          ctmp = [zeros(n, 1); ones(n_in, 1)];
+          lb = [-Inf(n,1); zeros(n_in,1)];
           ub = [];
           ctype = repmat ("L", n_in, 1);
           [P, dummy, status] = glpk (ctmp, Atmp, btmp, lb, ub, ctype);

I'm re-opening and marking it as a regression.

Lacklan, any insight into this?

(file #39742)

Ben Abbott <bpabbott>
Project Member
Mon 08 Aug 2016 10:13:47 PM UTC, comment #3: 

@Lachlan: I pushed your patch here http://hg.savannah.gnu.org/hgweb/octave/rev/20e0c0b8820c.  This must have been one of the first patches you wrote since I corrected syntax things like using '%' as the comment character.  Thanks for all the help with these old reports.

Rik <rik5>
Project Administrator
Sat 27 Feb 2016 05:23:14 AM UTC, comment #2: 

There seem to be two problems here.

The clearest problem is that qp.m uses the wrong size matrices for C and the lower bound.  From the comments in the code, Ain must have n columns (as it is multiplied by x), but a value of n-n_eq was being used.

I don't really understand the algorithm, so I can't confirm that that is the only bug, but since it is just changing the size of a vector of zeros or infinities, I assume that is the right fix.

Once that is fixed, qp returns an infeasible solution, and returns  lambda=[].  This causes an error in sqp, so this patch sets lambda to its previous value if qp returns an infeasible solution.  A warning is shown anyway, so the user knows not to trust the results; this just prevents an inexplicable error.

It would be great if someone who understands this code could check the changes.

(file #36487)

Lachlan Andrew <lachlan>
Fri 08 Nov 2013 09:38:30 PM UTC, comment #1: 

The problem is still here in Octave 3.7.7+ (3851e5fde76d)

Julien Bect <jbect>
Tue 27 Mar 2012 03:28:12 PM UTC, original submission:  

The following code


function res=cef(x)
res=[0 0 0]';

function res=cif(x)
res=[1 3 -4; 3 -2 2; 1 1 0]*x.^2;


results in the error:

error: glpk: A must be a real valued 9 by 9 matrix
error: called from:
error:   /usr/share/octave/3.6.1/m/optimization/glpk.m at line 491, column 5
error:   /usr/share/octave/3.6.1/m/optimization/qp.m at line 366, column 33
error:   /usr/share/octave/3.6.1/m/optimization/sqp.m at line 414, column 32

I found this bug report in an old set of messages that were never correctly posted to the -email is unavailable- mailing list.
Sorry for not posting it before now.

John W. Eaton <jwe>
Project Administrator


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

Attach Files:

Attached Files
file #39748:  changeset.patch added by bpabbott (2KiB - application/octet-stream)
file #39742:  test_qp.m added by bpabbott (231B - application/octet-stream)
file #36487:  bug_36015_sqp.cset added by lachlan (3KiB - text/x-diff)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by bpabbott (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by lachlan (Updated the item)
  • -email is unavailable- added by jbect (Posted a comment)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by jwe (Submitted the item)
  • -email is unavailable- added by jwe

    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 project members can vote.





    Follow 16 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-03-27 rik5 StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2017-02-13 bpabbott Attached File- Added changeset.patch, #39748
    2017-02-12 bpabbott Attached File- Added test_qp.m, #39742
        Item GroupIncorrect Result Regression
        StatusFixed Need Info
        Open/ClosedClosed Open
    2016-08-08 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2016-02-27 lachlan Attached File- Added bug_36015_sqp.cset, #36487
        StatusConfirmed Patch Submitted
        Assigned toNone lachlan
    2013-10-28 mtmiller CategoryLibraries Octave Function
        StatusNone Confirmed
        Release3.6.1 dev
    2012-03-27 jwe Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.9