error: quadprog: equality constraint matrix has incorrect column dimension

classic Classic list List threaded Threaded
5 messages Options
ola
Reply | Threaded
Open this post in threaded view
|

error: quadprog: equality constraint matrix has incorrect column dimension

ola
I try to use lsqlin solver from optim package in c++ implementation. My code
is compiled, but returns an error when executing:
*error: quadprog: equality constraint matrix has incorrect column dimension*

I use octave 4.4.0 and optim 1.5.3.
Here is the code:  test_lsqlin.cc
<http://octave.1599824.n4.nabble.com/file/t373160/test_lsqlin.cc>  

I also tried to set the exact column dimension in the equality constraint
matrix (in my code matrix c), but it also doesn't work.
In my case matrices/vectors: A, b, Aeq, beq, x0 should be empty (x =
lsqlin(C,d,A,b,Aeq,beq,lb,ub,x0,options)).
Could you help me, what am I doing wrong?



-----
ola
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


ola
Reply | Threaded
Open this post in threaded view
|

Re: error: quadprog: equality constraint matrix has incorrect column dimension

Andreas Weber-6
Am 18.01.19 um 11:12 schrieb ola:
> I try to use lsqlin solver from optim package in c++ implementation. My code
> is compiled, but returns an error when executing:
> *error: quadprog: equality constraint matrix has incorrect column dimension*

Have you tried to write a .m files with your parameter first and run it?
-- Andy


ola
Reply | Threaded
Open this post in threaded view
|

Re: error: quadprog: equality constraint matrix has incorrect column dimension

ola
No, I have not. I don't know how to write and use .m files.
My target code is much larger and more complicated and must be in c++. The
lsqlin() function returned an error so I wrote test_lsqlin - the shortest
possible code using this function and also doesn't work.
Do you know how to solve this problem in octave standalone application?
My input equality constraint matrix should be empty and from what I
understand the algorithm itself will change its size if it's needed. So why
the error with matrix column dimension occur?
I will be very grateful for your help. :)



-----
ola
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


ola
ola
Reply | Threaded
Open this post in threaded view
|

Re: error: quadprog: equality constraint matrix has incorrect column dimension

ola
In reply to this post by Andreas Weber-6
Okey, so I have tried in a command line octave sth like this:
/>pkg load optim
>    C = [1, 1, 1, 1, 1;
              1, 1, 1, 1, 0;
              1, 1, 0, 0, 1;
              1, 0, 1, 0, 0];
>d = [1; .7; .7; .01];
>lb = zeros (5, 1);
>ub = ones (5, 1);
>x = lsqlin (C, d, [], [], [], [], lb, ub)/
Return the same quadprog error.
But example from https://octave.sourceforge.io/optim/function/lsqlin.html
works well.
So, I have tried few combinations and I found that only x = lsqlin (C, d, A,
b, [], [], lb, ub) works. Aeq, beq - Linear equality constraint
matrix/vector could be empty, but empty A, b - Linear inequality constraint
matrix/vector returns quadprog error.
So, what should I put to these matrices (A,b) if I don't have any values.
Should it be empty, but with known dimension matrix or zeros matrix or ones
matrix?





-----
ola
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


ola
Reply | Threaded
Open this post in threaded view
|

Re: error: quadprog: equality constraint matrix has incorrect column dimension

siko1056
On Fri, Jan 18, 2019 at 1:38 PM ola <[hidden email]> wrote:
Okey, so I have tried in a command line octave sth like this:
/>pkg load optim
>    C = [1, 1, 1, 1, 1;
              1, 1, 1, 1, 0;
              1, 1, 0, 0, 1;
              1, 0, 1, 0, 0];
>d = [1; .7; .7; .01];
>lb = zeros (5, 1);
>ub = ones (5, 1);
>x = lsqlin (C, d, [], [], [], [], lb, ub)/
Return the same quadprog error.
But example from https://octave.sourceforge.io/optim/function/lsqlin.html
works well.
So, I have tried few combinations and I found that only x = lsqlin (C, d, A,
b, [], [], lb, ub) works. Aeq, beq - Linear equality constraint
matrix/vector could be empty, but empty A, b - Linear inequality constraint
matrix/vector returns quadprog error.
So, what should I put to these matrices (A,b) if I don't have any values.
Should it be empty, but with known dimension matrix or zeros matrix or ones
matrix?

-----
ola
--

You probably found a bug in lsqlin.  The problem is (but should not be) that you provide all empty constraints: A = b = Aeq = beq = [].


In short: `horzcat ({1},[],{2})` will evaluate to `{1, 2}` not `{1, [], 2}`.

A fix is to surround the arguments "{A}" and "{b}" in the aforementioned line.


Best,
Kai