Hello,
I need to use variables with three or more indices. To simplify modelling, it would be thus useful if I could create optimization variables with three or more dimensions; as far as I can see, however, in cvxpy it is only possible to create up to two dimensional arrays.
To handle the extra dimensions using 2 dimensional arrays, I thus have to squeeze the extra dimensions in the two I have. Then, to perform summations only over certain dimensions, I am thinking of creating lists of tuples that will select only certain elements of the optimization variable.
Something along the lines of:
x = cvx.Variable(2,2)
interesting_indices = [(0,0),(1,1)]
constraints = [sum([x[i] for i in interesting_indices]) <= 0.5]
to, e.g., perform the summation only over certain selected entries - which seems to work.
Is there a better way to handle higher dimensions / variables indexing in cvxpy?
For instance, it would be useful if we could plug Variable objects into numpy structures, as in
x = np.empty((3,3,3), dtype=object)
x[:,:,:] = cvx.Variable()
to create a three dimensional array, and then work with x as any other numpy array (also in terms of indexing).
Thank you!