Quadratic Programming with CPLEX and JuMP

It has been a while that CPLEX can solve nonconvex quadratic programming problems. But I am wondering if that has been considered in JuMP.
The reason I am asking is that I coded the following:

Q=[-50.0    0.0    0.0    0.0    0.0  42.0
   0.0  -50.0    0.0    0.0    0.0  44.0
   0.0    0.0  -50.0    0.0    0.0  45.0
   0.0    0.0    0.0  -50.0    0.0  47.0
   0.0    0.0    0.0    0.0  -50.0  47.5
  42.0   44.0   45.0   47.0   47.5  -0.0];
  A_x=[ 1.0   0.0   0.0  0.0  0.0   0.0
  0.0   1.0   0.0  0.0  0.0   0.0
  0.0   0.0   1.0  0.0  0.0   0.0
  0.0   0.0   0.0  1.0  0.0   0.0
  0.0   0.0   0.0  0.0  1.0   0.0
  0.0   0.0   0.0  0.0  0.0   1.0
  0.0   0.0   0.0  0.0  0.0  -1.0
 20.0  12.0  11.0  7.0  4.0   0.0];
 b_x=[1.0
  1.0
  1.0
  1.0
  1.0
  0.5
 -0.5
 40.0]
n=6;
model = Model(CPLEX.Optimizer)
@variable(model, x[1:n]>=0)
@objective(model, Min, x'*Q*x)
con = @constraint(model, A_x*x .<= b_x)
sol_cplex=optimize!(model)

in Julia 1.5.3 using JuMP 0.21.5 and CPLEX 12.10, and got the following error:

ERROR: LoadError: CPLEX Error  5002: %s is not convex.

Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] _check_ret(::CPLEX.Env, ::Int32) at C:\Users\20176914\.julia\packages\CPLEX\uUjlQ\src\MOI\MOI_wrapper.jl:126
 [3] _check_ret at C:\Users\20176914\.julia\packages\CPLEX\uUjlQ\src\MOI\MOI_wrapper.jl:243 [inlined]
 [4] _optimize!(::CPLEX.Optimizer) at C:\Users\20176914\.julia\packages\CPLEX\uUjlQ\src\MOI\MOI_wrapper.jl:2431
 [5] optimize!(::CPLEX.Optimizer) at C:\Users\20176914\.julia\packages\CPLEX\uUjlQ\src\MOI\MOI_wrapper.jl:2488
 [6] optimize!(::MathOptInterface.Bridges.LazyBridgeOptimizer{CPLEX.Optimizer}) at C:\Users\20176914\.julia\packages\MathOptInterface\ZJFKw\src\Bridges\bridge_optimizer.jl:264
 [7] optimize!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at C:\Users\20176914\.julia\packages\MathOptInterface\ZJFKw\src\Utilities\cachingoptimizer.jl:215
 [8] optimize!(::Model, ::Nothing; bridge_constraints::Bool, ignore_optimize_hook::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\20176914\.julia\packages\JuMP\qhoVb\src\optimizer_interface.jl:130
 [9] optimize! at C:\Users\20176914\.julia\packages\JuMP\qhoVb\src\optimizer_interface.jl:106 [inlined] (repeats 2 times)
 [10] top-level scope at C:\Users\20176914\surfdrive\scientific\University\Codes\MATLAB\Bilinearprog\readLP.jl:46
 [11] include(::String) at .\client.jl:457
 [12] top-level scope at REPL[2]:1
in expression starting at C:\Users\20176914\surfdrive\scientific\University\Codes\MATLAB\Bilinearprog\readLP.jl:46

I know from past experience that there are different functions to make the distinction between convex and non-convex. So, I am now wondering if it is only possible to solve convex QPs in JuMP using CPLEX.
Does anyone have any experience with that?

CPLEX does not support non-convex QPs. I think you are thinking of Gurobi: https://www.gurobi.com/resource/non-convex-quadratic-optimization/

2 Likes

CPLEX does support non-convex QP, just not non-convex QCQP.

@ahmadreza-marandi as mentioned in the CPLEX documentation, you need to set the optimality target parameter accordingly:

By default, CPLEX terminates if the quadratic objective term in a QP is found to be non PSD. In such a case, in order to instruct CPLEX not to terminate, you must set the optimality target parameter. The value that you set for that parameter depends on the type of results that you expect. If you would like CPLEX to compute a point that satisfies first-order optimality conditions (that is, a local optimum), then you set the parameter to the value CPX_SOLUTIONTARGET_FIRSTORDER. If you would like CPLEX to find a global optimum , then you set the parameter to the value CPX_SOLUTIONTARGET_OPTIMALGLOBAL.

Just add the following line:

set_optimizer_attribute(model, "CPXPARAM_OptimalityTarget", 3)
2 Likes

My mistake!

1 Like

@mtanneau: that was a great help. Thanks. I missed that parameter.