0

I am not able to select the cplex solver for cvxpy. The cvxpy website states that if you're able to import cplex into python, you will also be able to use cplex for cvxpy. However, this is not the case.

CPLEX is not one of the arguments of cvxpy. See the list of arguments for cvxpy below.

How to solve this?

dir(cp)
Out[8]: 
['Bool',
 'CBC',
 'CVXOPT',
 'CallbackParam',
 'Constant',
 'ECOS',
 'ECOS_BB',
 'ELEMENTAL',
 'GLPK',
 'GLPK_MI',
 'GUROBI',
 'INFEASIBLE',
 'INFEASIBLE_INACCURATE',
 'Int',
 'JULIA_OPT',
 'LS',
 'MOSEK',
 'Maximize',
 'Minimize',
 'NonNegative',
 'OPTIMAL',
 'OPTIMAL_INACCURATE',
 'Parameter',
 'Problem',
 'ROBUST_KKTSOLVER',
 'SCS',
 'SOLVER_ERROR',
 'Semidef',
 'SolverError',
 'Symmetric',
 'UNBOUNDED',
 'UNBOUNDED_INACCURATE',
 'Variable',
 '__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 '__version__',
 'abs',
 'affine',
 'affine_prod',
 'atom',
 'atoms',
 'axis_atom',
 'bmat',
 'constraints',
 'conv',
 'cumsum',
 'diag',
 'diff',
 'elementwise',
 'entr',
 'error',
 'exp',
 'expressions',
 'geo_mean',
 'harmonic_mean',
 'hstack',
 'huber',
 'installed_solvers',
 'interface',
 'inv_pos',
 'kl_div',
 'kron',
 'lambda_max',
 'lambda_min',
 'lambda_sum_largest',
 'lambda_sum_smallest',
 'lin_ops',
 'linearize',
 'log',
 'log1p',
 'log_det',
 'log_sum_exp',
 'logistic',
 'matrix_frac',
 'max_elemwise',
 'max_entries',
 'min_elemwise',
 'min_entries',
 'mixed_norm',
 'mul_elemwise',
 'neg',
 'norm',
 'norm1',
 'norm2',
 'normInf',
 'normNuc',
 'norm_inf',
 'norm_nuc',
 'partial_optimize',
 'pnorm',
 'pos',
 'power',
 'problems',
 'quad_form',
 'quad_over_lin',
 'reshape',
 'scalene',
 'semidefinite',
 'settings',
 'sigma_max',
 'sqrt',
 'square',
 'sum_entries',
 'sum_largest',
 'sum_smallest',
 'sum_squares',
 'total_variation',
 'trace',
 'transforms',
 'tv',
 'upper_tri',
 'utilities',
 'vec',
 'vstack']
Wiet
  • 21
  • 2

1 Answers1

0

The zoo and bus example:

# Import packages.
import cvxpy as cp

# Define and solve the CVXPY problem.
nbBus40 = cp.Variable(integer=True)
nbBus30 = cp.Variable( integer=True)
cost = 500*nbBus40+400*nbBus30
prob = cp.Problem(cp.Minimize(cost),[40*nbBus40+30*nbBus30>=300,
                                     nbBus40>=0,nbBus30>=0
                                     ])
prob.solve(solver=cp.CPLEX,verbose=True)
# Print result.
print("\nThe minimal cost is", prob.value)
print("number buses 40 seats = ",nbBus40.value)
print("number buses 30 seats = ",nbBus30.value)

works fine

Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15