Stop Julia at certain optimiality gap and return decision variables


#1

I have a MILP problem and I am trying to solve it using CPLEX package through JuMP in Julia Language. However, the problem takes a long time to be solved. Is there a way to stop the program and return decision variables when the optimality gap reaches for example 10%. Thank you.


#2

I haven’t used CPLEX, but I believe you can do:

m = Model(solver=CplexSolver(CPX_PARAM_EPGAP=1e-2))

or

setsolver(m, CplexSolver(CPX_PARAM_EPGAP=1e-2))

#3

(the above assumes you are using CPLEX through JuMP, which I just realized you didn’t actually say).


#4

Thank you, it works.


#5

Yes, I am using CPLEX through JuMP.
Sorry for not mentioning it.


#6

Hi @rdeits,

I am using Julia 1.1.0 and following packages:

“Clp” => v"0.6.1"
“Atom” => v"0.7.14"
“CPLEX” => v"0.4.3"
“JuMP” => v"0.19.0"
“Juno” => v"0.5.4"
“Conda” => v"1.2.0"
“ExcelReaders” => v"0.10.3"
“MathProgBase” => v"0.7.7"
“XLSX” => v"0.4.6"
“Cbc” => v"0.6.0"
“DataFrames” => v"0.17.1".

I am trying to set m = Model(solver=CplexSolver(CPX_PARAM_EPGAP=1e-2)), but I am getting the following error:

The solver= keyword is no longer available in JuMP 0.19 and later.

However, they are suggesting a link for the reference which is somehow not a valid link.

Any help in this regard would be highly appreciated. Also, could you please share any link where I can find how to set different stopping criteria for the CPLEX solver through JuMP?


#7

JuMP has been updated.

The new syntax is

m = Model(with_optimizer(CPLEX.Optimizer, CPX_PARAM_EPGAP=1e-2))

#8

Thanks, @odow . Any idea where can I find the list of keywords to set the stopping criteria, example: absolute MIP gap, relative MIP gap, time etc.? Also, is there a way to set a warm start?


#9

The list of CPLEX parameters can be found here: https://www.ibm.com/support/knowledgecenter/en/SS9UKU_12.8.0/com.ibm.cplex.zos.help/CPLEX/Parameters/topics/introListAlpha.html

Warmstarts can set set using

These were mistakenly missing from the docs: https://github.com/JuliaOpt/JuMP.jl/issues/1871


#10

You’ll soon discover that it’s extremely clunky to navigate the parameter list using the web interface. Luckily IBM also makes a nice easily searchable PDF of the whole thing, but to my knowledge they don’t actually link to it anywhere. Some time ago I googled my way to an old version and then found the latest one by just modifying the URL:

By the way, I think the old parameter names are being deprecated. So if you want to future proof your code you may want to use the newer more verbose names, e.g. CPXPARAM_MIP_Tolerances_MIPGap instead of CPX_PARAM_EPGAP.