# Getting Gap and #Nodes in JuMP v0.19

**URL:** <https://discourse.julialang.org/t/getting-gap-and-nodes-in-jump-v0-19/22566>\
**Category:** Optimization (Mathematical)\
**Created:** [March 31, 2019, 3:58pm UTC](https://discourse.julialang.org/t/getting-gap-and-nodes-in-jump-v0-19/22566 "2019-03-31T15:58:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Post date:** [March 31, 2019, 3:58pm UTC](https://discourse.julialang.org/t/getting-gap-and-nodes-in-jump-v0-19/22566/1 "2019-03-31T15:58:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [March 31, 2019, 4:08pm UTC](https://discourse.julialang.org/t/getting-gap-and-nodes-in-jump-v0-19/22566/2 "2019-03-31T16:08:30Z")

</div>

Please provide a MWE [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757) and quote your code [PSA: how to quote code with backticks](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530).

---

<div class="post-metadata">

**Author:** ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Post date:** [March 31, 2019, 4:43pm UTC](https://discourse.julialang.org/t/getting-gap-and-nodes-in-jump-v0-19/22566/3 "2019-03-31T16:43:20Z")

</div>

My code is:

```julia
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.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [March 31, 2019, 5:32pm UTC](https://discourse.julialang.org/t/getting-gap-and-nodes-in-jump-v0-19/22566/4 "2019-03-31T17:32:55Z")

</div>

@angeloaliano1 you have already asked this [question](https://discourse.julialang.org/t/query-solution-time/22263/6) ([twice](https://discourse.julialang.org/t/gap-and-cputime-in-jump-v0-19/22521/6)) and gotten a reply.

> [@Query Solution Time](https://discourse.julialang.org/t/query-solution-time/22263/7):
>
> RelativeGap isn’t implemented for CPLEX yet. I’ve opened an issue: [MOI: implement RelativeGap · Issue #228 · jump-dev/CPLEX.jl · GitHub](https://github.com/JuliaOpt/CPLEX.jl/issues/228)

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](https://github.com/JuliaOpt/CPLEX.jl/issues/228)) and we can point you in the right direction for how to make the fix.

---

<div class="post-metadata">

**Author:** ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Post date:** [March 31, 2019, 9:12pm UTC](https://discourse.julialang.org/t/getting-gap-and-nodes-in-jump-v0-19/22566/5 "2019-03-31T21:12:11Z")

</div>

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.
