# Problems in obtaing of the Relative Gap

**URL:** https://discourse.julialang.org/t/problems-in-obtaing-of-the-relative-gap/34433
**Category:** Optimization (Mathematical)
**Created:** [February 10, 2020, 8:34pm UTC](https://discourse.julialang.org/t/problems-in-obtaing-of-the-relative-gap/34433 "2020-02-10T20:34:13Z")
**Posts on this page:** 3
**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: [February 10, 2020, 8:34pm UTC](https://discourse.julialang.org/t/problems-in-obtaing-of-the-relative-gap/34433/1 "2020-02-10T20:34:13Z")

</div>

I have the following simple problem:

```julia
using JuMP
using CPLEX
m = Model(with_optimizer(CPLEX.Optimizer))

c = [1; 2; 5]
A = [-1 1 3;
      1 3 -7]
b = [-5; 10]

@variable(m, x[1:3] >= 0)
@objective(m, Max, sum( c[i]*x[i] for i=1:3) )

@constraint(m, constraint[j=1:2], sum( A[j,i]*x[i] for i=1:3 ) <= b[j] )

@constraint(m, bound, x[1] <= 10)

optimize!(m)

print(m)

println("Optimal Solutions:")
for i=1:3
  println("x[$i] = ", getvalue(x[i]))
end

println("Dual Variables:")
for j=1:2
  println("dual[$j] = ", getdual(constraint[j]))
end

x_value = JuMP.value.(x)
time = MOI.get(m, MOI.SolveTime())
Gap = MOI.get(m, MOI.RelativeGap())

```

When I insert the command `Gap = MOI.get(m, MOI.RelativeGap())` a error message appears:

```julia
ethodError: no method matching get(::Model, ::MathOptInterface.RelativeGap)
Closest candidates are:
  get(!Matched::REPL.Terminals.TTYTerminal, ::Any, !Matched::Any) at C:\Users\julia\AppData\Local\Julia-1.0.4\share\julia\stdlib\v1.0\REPL\src\Terminals.jl:176
  get(!Matched::IdDict{K,V}, ::Any, !Matched::Any) where {K, V} at abstractdict.jl:597
  get(!Matched::Base.Iterators.Pairs, ::Any, !Matched::Any) at iterators.jl:252
  ...
top-level scope at none:0

```

Anyone could help me please?  
For a long time this have been a problem for me!

---

<div class="post-metadata">

### Author: ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)
#### Post date: [February 10, 2020, 9:47pm UTC](https://discourse.julialang.org/t/problems-in-obtaing-of-the-relative-gap/34433/2 "2020-02-10T21:47:14Z")

</div>

Closing this thread because it’s a duplicate of [Obtaining Gap in integer programming - #3 by angeloaliano1](https://discourse.julialang.org/t/obtaining-gap-in-integer-programming/34377/3).

---

<div class="post-metadata">

### Author: ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)
#### Post date: [February 10, 2020, 9:47pm UTC](https://discourse.julialang.org/t/problems-in-obtaing-of-the-relative-gap/34433/3 "2020-02-10T21:47:18Z")

</div>


