4
$\begingroup$

The following code works:

import numpy as np
import cvxpy as cp
ci = np.array([10,7,6,3])
x = cp.Variable(len(ci),boolean=True)
objective = cp.Minimize(cp.sum_squares(ci@(2*x-1)))
problm = cp.Problem(objective)
_ = problm.solve()

However, if I pass a larger ci array, it doesn't work. Per recommendation here, I want to try GLPK instead. So, I change the last line:

_ = problm.solve(solver=cp.GLPK_MI)

This leads to the following error:

SolverError: Either candidate conic solvers (['GLPK_MI']) do not support the cones output by the problem (SOC), or there are not enough constraints in the problem.

Is it the way I'm specifying constraints works for the default solver but not for GLMK_MI?

$\endgroup$
  • 3
    $\begingroup$ You can only solve linear problems using GLPK, so GLPK sís imply not applicable to your problem. $\endgroup$ – ErlingMOSEK Jan 22 at 10:13
  • 1
    $\begingroup$ @ErlingMOSEK is correct. Try using Gurobi, CPLEX, or Mosek, if they are available to you. $\endgroup$ – Mark L. Stone Jan 22 at 13:02
  • $\begingroup$ @MarkLStone any reference on how much they cost? $\endgroup$ – Rohit Pandey Jan 22 at 17:28
  • $\begingroup$ MOSEK can be used for free for academics. Commercial pricing can be seen at mosek.com/sales/commercial-pricing $\endgroup$ – ErlingMOSEK Jan 23 at 11:33
  • $\begingroup$ CPLEX and Gurobi both have free academic licenses, which require verification that you are at a degree-granting academic institution. $\endgroup$ – prubin Sep 1 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.