Discussion:
SQP - Reducing Vector Size?
jjmilburn
2013-04-24 02:47:26 UTC
Permalink
After posting, I noticed that the problem may be that the initial x0 was
defined as a scalar, and this was affecting the result. I changed the
initial x0 to be the same size as "w", and now the error that occurs is:

octave:69> sqp(qw, @(w)cost(w),[],@(w)conEq(w))
error: operator *: nonconformant arguments (op1 is 50x51, op2 is 1x51)
error: evaluating argument list element number 1
error: evaluating argument list element number 1
error: called from:
error: /usr/share/octave/3.2.4/m/optimization/qp.m at line 238, column 19
error: /usr/share/octave/3.2.4/m/optimization/sqp.m at line 414, column 34
error: /home/josh/octaveExperiment/data/trainSVM.m at line 44, column 7

I am passing sqp a 1x51 decision variable vector. On a hunch, I changed my
funcition call to the following (qw transposed, or qw' as the initial
condition):

octave:69> sqp(qw', @(w)cost(w),[],@(w)conEq(w))

This worked, and it appears to run. I will continue to examine this, but
can someone confirm if sqp will only accept column vectors, not row vectors?

Thanks,




--
View this message in context: http://octave.1599824.n4.nabble.com/SQP-Reducing-Vector-Size-tp4652246p4652247.html
Sent from the Octave - General mailing list archive at Nabble.com.
jjmilburn
2013-04-24 02:24:50 UTC
Permalink
I am implementing SQP, using the following functions for my objective and
inequality constraints, respectively:

function obj = cost (w)
obj = 0.5*norm(w(1,1:columns(w)-1))^2;
obj;
endfunction

function c2 = inEq (w)
for i=1:50
% the below commented line (without w index reference)
works.
% c2(i,:) = w * 12.5-4;

% this is a test, the line below does not work
c2(i,:) = w(i)*12.5-4;
end
endfunction

When I run sqp via the following : sqpOut=sqp(0, @cost,[],@inEq), I receive
the error:
error: A(I): Index exceeds matrix dimension.
error: called from:
error: conEq at line 21, column 11
error: /usr/share/octave/3.2.4/m/optimization/sqp.m at line 361, column 8
error: /home/josh/octaveExperiment/data/trainSVM.m at line 44, column 7

When I perform a "size(w)" before running sqp, I get the following:
ans = 1 51
when I perform a "size(w)" after running the above sqp, I get the following:
ans = 1 1

Questions:
1) Why is SQP changing the size of my decision variable (w) vector?
2) how do I remedy this or modify my code to make it not behave in this
way?

As noted in the code comments, I am able to get this to work if I do not
reference w by index.





--
View this message in context: http://octave.1599824.n4.nabble.com/SQP-Reducing-Vector-Size-tp4652246.html
Sent from the Octave - General mailing list archive at Nabble.com.
Loading...