cvxgrp / qcml

A Python parser for generating Python/C/Matlab solver interfaces
Other
42 stars 9 forks source link

problem in python prob_to_socp #52

Closed steve3141 closed 9 years ago

steve3141 commented 9 years ago

There seems to be an error in the python packing code corresponding to a mixed quadratic/affine constraint, eg

square(norm(A*x)) - 2*b*x <= c

generates a line:

(params['b']).T = sp.coo_matrix((params['b']).T)

which produces the error:

AttributeError: attribute 'T' of 'numpy.ndarray' objects is not writable

I'm using numpy 14; it's possible that this -- ie assigning to a transpose -- used to work in version 13, I haven't checked, but in any case the transpose appears to be unnecessary.

(There is no such error with a pure affine constraint, it appears to be triggered by the combination of quadratic and affine)

Regards, Steve

echu commented 9 years ago

Can you give me some more information? What are the dimensions of A, b, and c?

Thanks!

On Mon, Sep 22, 2014 at 8:09 AM, steve3141 notifications@github.com wrote:

There seems to be an error in the python packing code corresponding to a mixed quadratic/affine constraint, eg

square(norm(A_x)) - 2_b*x <= c

generates a line:

(params['b']).T = sp.coo_matrix((params['b']).T)

which produces the error:

AttributeError: attribute 'T' of 'numpy.ndarray' objects is not writable

I'm using numpy 14; it's possible that this -- ie assigning to a transpose -- used to work in version 13, I haven't checked, but in any case the transpose appears to be unnecessary.

(There is no such error with a pure affine constraint, it appears to be triggered by the combination of quadratic and affine)

Regards, Steve

— Reply to this email directly or view it on GitHub https://github.com/cvxgrp/qcml/issues/52.

echu commented 9 years ago

i should point out that #45 affects this. so if your parameter b = np.matrix([1,2]) vs b = np.matrix([[1],[2]]) surprising things could happen. let me think of a good fix for this (possibly involving coercing parameters to the right shapes), but in the meantime, this specific issue is fixed.

steve3141 commented 9 years ago

Thanks, Eric, for the prompt (as always) response. As I've mentioned before I'm working in a pretty highly controlled environment at the moment so it will be a little while before I'm able to test this, but I'm sure from what you say that it is fixed. Thanks again. Steve

steve3141 commented 9 years ago

Re: #45. That unfortunately is a kind of a mess, if you'll forgive my saying so. The thing is that the very same expression is treated differently when it's a constraint than when it's an objective function. In one case you've got to provide a row, in the other case it has to be a column. It's hard to keep straight and get it right. (It's worth it, of course, since the program is tremendously useful!)