Issue Solving BQPs with JuMP+CPLEX


#1

I am having some trouble solving binary quadratic programs with JuMP and CPLEX. Here is some code that illustrates the problem:

import JuMP
import CPLEX

function bqp(Q, c)
	m = JuMP.Model(solver=CPLEX.CplexSolver())
	@JuMP.variable(m, x[1:size(Q, 1)], Bin)
	@JuMP.objective(m, Min, dot(x, Q * x) + dot(c, x))
	return JuMP.solve(m)
end

bqp(eye(2, 2), ones(2))

Running this produces the error, “CPLEX Error 1029: Not a MIQP or fixed MIQP.”. Am I doing something wrong? Is this an issue in JuMP or CPLEX? Any help would be much appreciated.

Dan


#2

It works perfectly in Gurobi.


#3

Maybe CPLEX only supports a quadratic object function, but not quadratic constraints (in combination with integer variables). That’s what QP (quadratic program) is usually used for, compared to QCQP (quadratically constrained QP).

EDIT: disregard that, your model has the objective.


#4

I can’t reproduce this. Which version of JuMP/CPLEX/CPLEX.jl are you using? (run Pkg.status() and CPLEX.version()).


#5
julia> Pkg.status()
...
 - CPLEX                         0.2.2
...
- JuMP                          0.16.1
...

julia> CPLEX.version()
"12.7.0.0"

julia> VERSION
v"0.5.1"

#6

Strange. Can you run Pkg.update() and then retry? Is there a more complete backtrace?


#7

I did the Pkg.update(), and ran the code again. I got the same error. Here is the full stack trace:

julia> bqp(eye(2, 2), ones(2))
CPLEX Error  1029: Not a MIQP or fixed MIQP.
ERROR: CPLEX.CplexError(1029,"CPLEX Error  1029: Not a MIQP or fixed MIQP.\n")
 in set_prob_type!(::CPLEX.Model, ::Int64) at /homedir/.julia/v0.5/CPLEX/src/cpx_model.jl:135
 in set_prob_type!(::CPLEX.Model, ::Symbol) at /homedir/.julia/v0.5/CPLEX/src/cpx_model.jl:138
 in toggleproblemtype!(::CPLEX.CplexMathProgModel) at /homedir/.julia/v0.5/CPLEX/src/CplexSolverInterface.jl:265
 in setvartype!(::CPLEX.CplexMathProgModel, ::Array{Symbol,1}) at /homedir/.julia/v0.5/CPLEX/src/CplexSolverInterface.jl:247
 in #build#114(::Bool, ::Bool, ::JuMP.ProblemTraits, ::Function, ::JuMP.Model) at /homedir/.julia/v0.5/JuMP/src/solvers.jl:440
 in (::JuMP.#kw##build)(::Array{Any,1}, ::JuMP.#build, ::JuMP.Model) at ./<missing>:0
 in #solve#109(::Bool, ::Bool, ::Bool, ::Array{Any,1}, ::Function, ::JuMP.Model) at /homedir/.julia/v0.5/JuMP/src/solvers.jl:166
 in bqp(::Array{Float64,2}, ::Array{Float64,1}) at ./REPL[4]:5

#8

Seems related to https://github.com/JuliaOpt/CPLEX.jl/issues/115. Run Pkg.update() again to get CPLEX.jl 0.2.3 after https://github.com/JuliaLang/METADATA.jl/pull/8314 is merged.


#9

Thanks! That resolved my issue.