# HG changeset patch # User Rik # Date 1544572843 28800 # Node ID aaa23f9845dd8d00a2fe6404893418ff6e3e86be # Parent cf037b842a9f02159a9f342bfaa2b77ebbfb030f qp.m: Allow empty inequality constraints (bug #38483). * qp.m: Change input validation to only process inequality constraints if A_in is non-empty. diff -r cf037b842a9f -r aaa23f9845dd scripts/optimization/qp.m --- a/scripts/optimization/qp.m Tue Dec 11 15:38:55 2018 -0800 +++ b/scripts/optimization/qp.m Tue Dec 11 16:00:43 2018 -0800 @@ -264,14 +264,18 @@ endif ## Validate inequality constraints. - if (nargs > 7) + if (nargs > 7 && isempty (A_in) && ! (isempty(A_lb) || isempty(A_ub))) + warning("qp: empty inequality constraint matrix but non-empty bound vectors"); + endif + + if (nargs > 7 && ! isempty (A_in)) [dimA_in, n1] = size (A_in); if (n1 != n) - error ("qp: inequality constraint matrix has incorrect column dimension"); + error ("qp: inequality constraint matrix has incorrect column dimension, expected %i", n1); else if (! isempty (A_lb)) if (numel (A_lb) != dimA_in) - error ("qp: inequality constraint matrix and lower bound vector are inconsistent"); + error ("qp: inequality constraint matrix and lower bound vector are inconsistent, %i != %i", dimA_in, numel (A_lb)); elseif (isempty (A_ub)) Ain = [Ain; A_in]; bin = [bin; A_lb]; @@ -279,7 +283,7 @@ endif if (! isempty (A_ub)) if (numel (A_ub) != dimA_in) - error ("qp: inequality constraint matrix and upper bound vector are inconsistent"); + error ("qp: inequality constraint matrix and upper bound vector are inconsistent, %i != %i", dimA_in, numel (A_ub)); elseif (isempty (A_lb)) Ain = [Ain; -A_in]; bin = [bin; -A_ub];