lsqlin fails but quadprog works

2 次查看(过去 30 天)
Bill Woessner
Bill Woessner 2012-10-16
I'm trying to solve a linear least squares problem with bounds and linear equality constraints. Obviously, I reached for lsqlin. Here's my input:
N = 100;
C = [speye(N), spalloc(N, N, 0)]
d is N x 1
Aeq is N - 2 x 2N with rank N - 2
beq = zeros(N - 2, 1);
lb = [-inf(N, 1); -ones(N, 1)]
ub = [inf(N, 1); ones(N, 1)];
x0 = [d; zeros(N, 1)];
options = optimset('LargeScale', 'off');
x = lsqlin(C, d, [], [], Aeq, beq, lb, ub, x0, options);
And when I run it, I get the message:
Exiting: the solution is unbounded and at infinity;
the constraints are not restrictive enough.
I know from the formulation of the problem that this is not the case. So after double and triple checking all the inputs, I decided to reach for quadprog:
x = quadprog(C' * C, -C' * d, [], [], Aeq, beq, lb, ub, x0, options);
Sure enough, quadprog works like a champ. Even though C'C is singular, I get the right answer. Any insights as to why lsqlin fails but quadprog works?
Thanks in advance, Bill
  2 个评论
Matt J
Matt J 2012-10-16
编辑:Matt J 2012-10-16
It seems strange, but there are more things you can investigate. Impose large but finite lb(i) and ub(i) for i=1...N. This will allow lsqlin to complete its optimization. Then take the solution it gives you, check it for feasibility, and see if it obtains an objective function value competitive with quadprog.
Matt J
Matt J 2012-10-16
编辑:Matt J 2012-10-16
One another comment, though it may or may not be related to the error you are seeing. If your linear constraints Aeq*x=beq is a rank N-2 system, that means it specifies a 2 dimensional set of x. The null-space of C is an N-dimensional set. The intersection of these 2 sets will give the dimension of your solution space, if you ignore lb and ub. Thus, it seems that you should have at least a 1-dimensional set of solutions, making your problem under-determined. Adding inequality bounds won't change this, of course. They can only make a continuum of solutions bounded, not unique.

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by