I am very new to Julia and JuMP. I am using CPLEX 12.8 together with my optimization problem.
Instead of using self-defined time function to capture the total time spent in the optimization process, is there a direct way to print out the total time (root+branch-and-cut) of CPLEX?
I try to use SolveTime() in MathOptInterface (v0.8.4) but it didn’t work.
When I typed MathOptInterface.SolveTime(), the result just give me
And when I typed MathOptInterface.SolveTime(problem1), the error said
MethodError: no method matching MathOptInterface.SolveTime(::Model)
Closest candidates are:
MathOptInterface.SolveTime() at path
It would be nice if someone can show me how to correctly use the code since I also need to get the information of relative gap as well.
Thank you so much.
In MathOptInterface, you should use the
get method to query different results from a model (or variable etc.). See the example in the docs where
TerminationStatus is queried.
SolveTime should work in the same way.
Thank you for your reply. However, I tried the example code, it gave me error again.
Here is what I typed
status = MOI.get(problem1, TerminationStatus())
total_time = MOI.get(problem1, SolveTime())
The error is like this:
UndefVarError: TerminationStatus not defined
UndefVarError: SolveTime not defined
I am pretty sure I declare the package already, but I don’t know why I can’t use the get method of MathOptInterface. Could you give me some insight? Thank you.
You need to prepend
Oh that explains it!!! Thank you so much! Now I can move on…thank you!!
Hello sorry to bother again,
When I tried the same way to retrieve MIP relative gap, it gave me error again.
gap_info = MOI.get(model, MOI.RelativeGap())
The error message is
MethodError: no method matching get_relative_mip_gap(::CPLEX.Optimizer)
Closest candidates are:
However, I used the same code to retrieve
ObjectiveBound() it works. It seems like some of the attributes are not working. Could you give me some insight about why would this happen? Thank you.
RelativeGap isn’t implemented for CPLEX yet.
I’ve opened an issue: https://github.com/JuliaOpt/CPLEX.jl/issues/228
How can I obtain the relative Gap, If are not implemented?
I guess we need to calculate by ourselves. Just use the definition of Gap and manually record the best incumbent and best bound.
I really hope this issue can be solved. It would make things easier to get the value of incumbent, best bound, root relaxation gap and computational time for people who work in MIP problems…Is there anything I can do?
I can’t to implement in CPLEX.jl.
I made a issue in https://github.com/JuliaOpt/CPLEX.jl and requested to implement in a new version. Let go to wait.