CVXPY problem too big? Needing help on reformulating the problem

Hi everyone.

I am trying to solve an optimization problem with cvxpy. When the problem is being compiled, I get a “negative dimension” error, which could be because of an integer overflow problem. See topic on https://github.com/cvxgrp/cvxpy/issues/826 for more details.

My question is if you have an idea on how I could reformulate the problem formulation, so that the problem construct becomes smaller. Do you see any ways, where I could maybe use other functions or another mathematical formulation to reduce the problem?

The problem formulation in cvxpy and python:

X_opt = cp.Constant(np.asarray(X.iloc[:,:500])) # the array size is (35136,500)
K_opt = cp.Constant(np.asarray(K.YearlyDemand)) # the vector size is 96
b = cp.Variable((500,96),boolean = True, value = np.zeros((500,96)))
Y_opt = cp.Constant(np.asarray(y)) # the vector size is 35136

constraints = []

constraints.append( cp.sum(b, axis = 0) == 1 ) # the sum of the elements of every column of b must be equal to 1
constraints.append( cp.sum(b, axis = 1) <= 1 ) # the sum of the elements of every row of b must be smaller or equal to 1

objective = cp.Minimize(cp.sum(cp.abs(Y_opt-cp.sum((cp.diag(K_opt)@((X_opt@b).T)).T, axis = 1))))

prob = cp.Problem(objective, constraints)

prob.solve(solver = cp.GLPK_MI, verbose = True)

Thanks in advance

1 Like

CVXPY is different than CVX, which is the topic of this forum.

I suggest you post your question at https://groups.google.com/forum/#!forum/cvxpy .

1 Like