Getting Gap and #Nodes in JuMP v0.19

#1

Dear users,
I have tried to use the command
GAP = MOI.get(model, MOI.RelativeGap())
Nodes = MOI.get(modelo, MOI.NodeCount())
to obtain the relative GAP of my solution. Some colleagues in this group helped me, but this function does not work yet. The error appear:

ERROR: MethodError: no method matching get_relative_mip_gap(::CPLEX.Optimizer)

Is there some date to this function works? I need to my research.
Thanks a lot.

#2

Please provide a MWE PSA: make it easier to help you and quote your code PSA: how to quote code with backticks.

#3

My code is:

using JuMP, CPLEX
model = Model(with_optimizer(CPLEX.Optimizer))

@variable(model, 0 <= x <= 2, Int)
@variable(model, 0 <= y <= 30, Int)

@objective(model, Max, 5x + 3y)
@constraint(model, 1x + 5y <= 3.0)
JuMP.optimize!(model)

obj_value = JuMP.objective_value(model)
x_value = JuMP.value(x)
y_value = JuMP.value(y)
GAP = MOI.get(model, MOI.RelativeGap())
Num_nos = MOI.get(model, MOI.NodeCount())

The problem is the two last lines.
Thank you to help me.

#4

@angeloaliano1 you have already asked this question (twice) and gotten a reply.

In order to get it to work, you will have to implement the function in CPLEX.jl.

If you’re interested, post on the issue (https://github.com/JuliaOpt/CPLEX.jl/issues/228) and we can point you in the right direction for how to make the fix.

1 Like
#5

I requested the inclusion of the MOI.get(modelo, MOI.RelativeGap()) in the next version of CPLEX.jl. Let’s wait for the next version.