Getting Gap and #Nodes in JuMP v0.19

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.

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

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)

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.

@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 (MOI: implement RelativeGap · Issue #228 · jump-dev/CPLEX.jl · GitHub) and we can point you in the right direction for how to make the fix.

1 Like

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.