cvxgrp / qcml

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

Indexing and slicing in QMCL problem strings #56

Closed JosepVirgili closed 7 years ago

JosepVirgili commented 7 years ago

Is there a way to slice and perform operations on the variables on the problem string.

I am looking for something similar to what is possible in CVXPY: http://www.cvxpy.org/en/latest/tutorial/functions/index.html?highlight=slicing#indexing-and-slicing

I would like to add constraints that contain a norm of a subset of a variable. Something like: norm(x[4:5],2)<=2

echu commented 7 years ago

I don't think there is, and that may have been a function of the ambiguity involved when a function is applied to, say, a sliced data matrix (sliced variables are straightforward).

In the meantime, there's two approaches:

If you need slicing, you have to declare a second variable and expand all the equations manually. For instance, Ax might become A1 x1 + A2 x2, where A = [A1 A2] and x = [x1; x2].

Another possibility is to declare a data matrix that does the slicing for you ( S=[0, 0; 0, 1] ) and use Sx where you need the slicing.

Hope that helps! On Thu, Jun 29, 2017 at 11:40 AM Josep Virgili notifications@github.com wrote:

Is there a way to slice and perform operations on the variables on the problem string.

I am looking for something similar to what is possible in CVXPY:

http://www.cvxpy.org/en/latest/tutorial/functions/index.html?highlight=slicing#indexing-and-slicing

I would like to add constraints that contain a norm of a subset of a variable. Something like: norm(x[4:5],2)<=2

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cvxgrp/qcml/issues/56, or mute the thread https://github.com/notifications/unsubscribe-auth/AADN0SyMo14OQgy8pEwDsum6agxmFxdRks5sI--2gaJpZM4OJtdX .