[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: quadprog->qp newbie help
From: |
Martin Helm |
Subject: |
Re: quadprog->qp newbie help |
Date: |
Tue, 27 Mar 2012 18:30:39 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120312 Thunderbird/11.0 |
Am 27.03.2012 14:29, schrieb MarkSheedy:
> Hello,
>
> I am converting some code that uses the MatLab quadprog function to the
> Octave qp function.
> To familiarise myself with the code (I am a MatLab & Octave newbie), I have
> tried the example given in the MatLab docs.
>
> http://www.mathworks.co.uk/help/toolbox/optim/ug/quadprog.html
>
> H = [1 -1; -1 2];
> f = [-2; -6];
> A = [1 1; -1 2; 2 1];
> b = [2; 2; 3];
> lb = zeros(2,1);
>
> ML: quadprog(H,f,A,b,[],[],lb,[],[],'Algorithm','active-set')
> Oct: = qp([], H,f, A,b, lb,[])
>
> Using MatLab, this exits with a global minimum ( x = [ 0.6667;1.3333 ] )
> Using Octave, this fails with the following
> "qp: equality constraint matrix must be full row rank"
>
> If I alter qp.m to remove this error, the function terminates, but with a
> local minimum that does not satisfy one of the constraints (x
> =[0.77143;1.37143 ] )
>
> Any help would be much appreciated.
>
> M.
>
Your problem is of course that the equality constraint Ax=b contains in
your case one redundant constraint. When you remove it (for example by
removing the last equation which is in reality just a linear combination
of the first two constraints) it gives you of course the correct result.
H = [1 -1; -1 2];
f = [-2; -6];
A = [1 1; -1 2];
b = [2; 2];
lb = zeros(2,1);
qp([], H,f, A,b, lb,[])
ans =
0.66667
1.33333
I think this reduction can easily be built into qp as an automatic feature.
Re: quadprog->qp newbie help,
Martin Helm <=