Skip to content

Gap in JuMP v0.19 #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Mar 31, 2019 · 11 comments · Fixed by #261
Closed

Gap in JuMP v0.19 #230

ghost opened this issue Mar 31, 2019 · 11 comments · Fixed by #261
Labels
Wrapper: MathOptInterface Relates to the MathOptInterface API

Comments

@ghost
Copy link

ghost commented Mar 31, 2019

Hello,
When I try to obtain in the MIP the relative gap and number of nodes, it gave me error:

gap_info = MOI.get(model, MOI.RelativeGap())
Num_nodes = MOI.get(model, MOI.NodeCount())

The error message is

MethodError: no method matching get_relative_mip_gap(::CPLEX.Optimizer)
Closest candidates are:
get_relative_mip_gap(!Matched::LinQuadOptInterface.MockLinQuadOptimizer) at

However, I used the same code to retrieve ObjectiveBound() and CPU time it works. It seems like some of the attributes are not working. Could you give me some insight about why would this happen or to implement in CPLEX.jl in a new version?
Thank you.

@odow
Copy link
Member

odow commented Mar 31, 2019

Hi @angeloaliano,

Welcome to CPLEX.jl!

or to implement in CPLEX.jl in a new version?

The steps to get this resolved are

  • Open a Julia REPL
  • Run ] dev CPLEX
  • Open ~/.julia/dev/CPLEX/src/MOI_wrapper.jl
  • Add the following function to that file
function LQOI.get_relative_mip_gap(model::Optimizer)
    return get_rel_gap(model.inner)
end

Let me know if you get stuck on any steps (I haven't for example, tested that the function works because I don't have CPLEX).

@ghost
Copy link
Author

ghost commented Mar 31, 2019 via email

@blegat
Copy link
Member

blegat commented Apr 1, 2019

I can not to remove it, because I don't have permission (in the pencil, say that I must to be a branch)

You should remove it in the file: ~/.julia/dev/CPLEX/test/MathOptInterface/MOI_wrapper.jl in your computer (and also remove the comma in the previous line).

@ghost
Copy link
Author

ghost commented Apr 1, 2019 via email

@odow
Copy link
Member

odow commented Apr 1, 2019

Unfortunately you can't attach files when replying via email. Please log-in to the Github web interface and re-post your reply.

@ghost
Copy link
Author

ghost commented Apr 1, 2019

Dear,
I tried to perform the changes in the archives, as you attached.
I
image (1)
image

n the ~.julia\packages\CPLEX\mo9kV\src\MOI_wrapper and in ~.julia\packages\CPLEX\mo9kV\test\MathOptInterface. But, when I run ] test CPLEX, a error message appears.
Also, I changed the archive in https://github.com/JuliaOpt/CPLEX.jl/blob/master/src/MOI_wrapper.jl, inserting the function
function LQOI.get_relative_mip_gap(model::Optimizer)
return get_rel_gap(model.inner)
end.
There is anything to I do yet?
Would you like to help me please?

image (1)
image

@blegat
Copy link
Member

blegat commented Apr 1, 2019

We cannot see the errors, can you scroll up and give a screenshot of the error messages ? Or just copy-paste them

@odow
Copy link
Member

odow commented Apr 1, 2019

One problem (that is not your fault) is linear10b. To fix, change line 29 to
"linear10", "linear10b", # requires interval

@ghost
Copy link
Author

ghost commented Apr 1, 2019

Dear all,
I made the corrections as above. But, when I run ] text CPLEX, the error appear yet. Follow the error messages.

test CPLEX
   Testing CPLEX
    Status `C:\Users\ANGELO~1\AppData\Local\Temp\jl_65AF.tmp\Manifest.toml`
  [a076750e] CPLEX v0.4.4
  [34da2185] Compat v2.1.0
  [f8899e07] LinQuadOptInterface v0.6.0
  [b8f27783] MathOptInterface v0.8.4
  [fdba3010] MathProgBase v0.7.7
  [2a0f44e3] Base64  [`@stdlib/Base64`]
  [ade2ca70] Dates  [`@stdlib/Dates`]
  [8bb1440f] DelimitedFiles  [`@stdlib/DelimitedFiles`]
  [8ba89e20] Distributed  [`@stdlib/Distributed`]
  [b77e0a4c] InteractiveUtils  [`@stdlib/InteractiveUtils`]
  [76f85450] LibGit2  [`@stdlib/LibGit2`]
  [8f399da3] Libdl  [`@stdlib/Libdl`]
  [37e2e46d] LinearAlgebra  [`@stdlib/LinearAlgebra`]
  [56ddb016] Logging  [`@stdlib/Logging`]
  [d6f4376e] Markdown  [`@stdlib/Markdown`]
  [a63ad114] Mmap  [`@stdlib/Mmap`]
  [44cfe95a] Pkg  [`@stdlib/Pkg`]
  [de0858da] Printf  [`@stdlib/Printf`]
  [3fa0cd96] REPL  [`@stdlib/REPL`]
  [9a3f8284] Random  [`@stdlib/Random`]
  [ea8e919c] SHA  [`@stdlib/SHA`]
  [9e88b42a] Serialization  [`@stdlib/Serialization`]
  [1a1011a3] SharedArrays  [`@stdlib/SharedArrays`]
  [6462fe0b] Sockets  [`@stdlib/Sockets`]
  [2f01184e] SparseArrays  [`@stdlib/SparseArrays`]
  [10745b16] Statistics  [`@stdlib/Statistics`]
  [8dfed614] Test  [`@stdlib/Test`]
  [cf7118a7] UUIDs  [`@stdlib/UUIDs`]
  [4ec0a83e] Unicode  [`@stdlib/Unicode`]
Test Summary: | Pass  Total
C_API         |   32     32
┌ Warning: `Pkg.dir(pkgname, paths...)` is deprecated; instead, do `import MathProgBase; joinpath(dirname(pathof(MathProgBase)), "..", paths...)`.
└ @ Pkg.API C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\Pkg\src\API.jl:395
┌ Warning: Element type Int64 does not have an infinite value. Note that this may artifically introduce ranged (two-sided) constraints. To avoid this, consider casting the problem data to Float64.
└ @ MathProgBase.HighLevelInterface C:\Users\angeloaliano\.julia\packages\MathProgBase\rVlFR\src\HighLevelInterface\HighLevelInterface.jl:9
┌ Warning: Element type Int64 does not have an infinite value. Note that this may artifically introduce ranged (two-sided) constraints. To avoid this, consider casting the problem data to Float64.
└ @ MathProgBase.HighLevelInterface C:\Users\angeloaliano\.julia\packages\MathProgBase\rVlFR\src\HighLevelInterface\HighLevelInterface.jl:9
┌ Warning: Element type Int64 does not have an infinite value. Note that this may artifically introduce ranged (two-sided) constraints. To avoid this, consider casting the problem data to Float64.
└ @ MathProgBase.HighLevelInterface C:\Users\angeloaliano\.julia\packages\MathProgBase\rVlFR\src\HighLevelInterface\HighLevelInterface.jl:9
┌ Warning: Element type Int64 does not have an infinite value. Note that this may artifically introduce ranged (two-sided) constraints. To avoid this, consider casting the problem data to Float64.
└ @ MathProgBase.HighLevelInterface C:\Users\angeloaliano\.julia\packages\MathProgBase\rVlFR\src\HighLevelInterface\HighLevelInterface.jl:9
┌ Warning: Element type Int64 does not have an infinite value. Note that this may artifically introduce ranged (two-sided) constraints. To avoid this, consider casting the problem data to Float64.
└ @ MathProgBase.HighLevelInterface C:\Users\angeloaliano\.julia\packages\MathProgBase\rVlFR\src\HighLevelInterface\HighLevelInterface.jl:9
┌ Warning: Element type Int64 does not have an infinite value. Note that this may artifically introduce ranged (two-sided) constraints. To avoid this, consider casting the problem data to Float64.
└ @ MathProgBase.HighLevelInterface C:\Users\angeloaliano\.julia\packages\MathProgBase\rVlFR\src\HighLevelInterface\HighLevelInterface.jl:9
Test Summary: | Pass  Total
MathProgBase  |  217    217
Min IP with constant: Test Failed at C:\Users\angeloaliano\.julia\packages\MathOptInterface\C3lip\src\Test\UnitTests\solve.jl:22
  Expression: MOI.get(model, MOI.ObjectiveBound()) <= 3.0
   Evaluated: 4.0 <= 3.0
Stacktrace:
 [1] solve_objbound_edge_cases(::CPLEX.Optimizer, ::MathOptInterface.Test.TestConfig) at C:\Users\angeloaliano\.julia\packages\MathOptInterface\C3lip\src\Test\UnitTests\solve.jl:22
 [2] macro expansion at C:\Users\angeloaliano\.julia\packages\MathOptInterface\C3lip\src\Test\config.jl:53 [inlined]
 [3] macro expansion at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\Test\src\Test.jl:1083 [inlined]
 [4] unittest(::CPLEX.Optimizer, ::MathOptInterface.Test.TestConfig, ::Array{String,1}) at C:\Users\angeloaliano\.julia\packages\MathOptInterface\C3lip\src\Test\config.jl:53
Max IP with constant: Test Failed at C:\Users\angeloaliano\.julia\packages\MathOptInterface\C3lip\src\Test\UnitTests\solve.jl:41
  Expression: MOI.get(model, MOI.ObjectiveBound()) >= 3.0
   Evaluated: 2.0 >= 3.0
Stacktrace:
 [1] macro expansion at C:\Users\angeloaliano\.julia\packages\MathOptInterface\C3lip\src\Test\UnitTests\solve.jl:41 [inlined]
 [2] macro expansion at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\Test\src\Test.jl:1083 [inlined]
 [3] solve_objbound_edge_cases(::CPLEX.Optimizer, ::MathOptInterface.Test.TestConfig) at C:\Users\angeloaliano\.julia\packages\MathOptInterface\C3lip\src\Test\UnitTests\solve.jl:27
Min LP with constant: Error During Test at C:\Users\angeloaliano\.julia\packages\MathOptInterface\C3lip\src\Test\UnitTests\solve.jl:59
  Test threw exception
  Expression: MOI.get(model, MOI.ObjectiveBound()) <= 2.0
  MethodError: no method matching CPLEX.CplexError(::Ptr{Nothing}, ::Int32)
  Closest candidates are:
    CPLEX.CplexError(!Matched::CPLEX.Env, ::Integer) at C:\Users\angeloaliano\.julia\packages\CPLEX\mo9kV\src\cpx_env.jl:90
  Stacktrace:
   [1] get_best_bound(::CPLEX.Model) at C:\Users\angeloaliano\.julia\packages\CPLEX\mo9kV\src\cpx_callbacks.jl:5
   [2] get_objective_bound(::CPLEX.Optimizer) at C:\Users\angeloaliano\.julia\packages\CPLEX\mo9kV\src\MOI_wrapper.jl:306
   [3] get at C:\Users\angeloaliano\.julia\packages\LinQuadOptInterface\ZMx9f\src\solve.jl:240 [inlined]
   [4] macro expansion at C:\Users\angeloaliano\.julia\packages\MathOptInterface\C3lip\src\Test\UnitTests\solve.jl:59 [inlined]
   [5] macro expansion at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\Test\src\Test.jl:1083 [inlined]
   [6] solve_objbound_edge_cases(::CPLEX.Optimizer, ::MathOptInterface.Test.TestConfig) at C:\Users\angeloaliano\.julia\packages\MathOptInterface\C3lip\src\Test\UnitTests\solve.jl:46
Max LP with constant: Error During Test at C:\Users\angeloaliano\.julia\packages\MathOptInterface\C3lip\src\Test\UnitTests\solve.jl:77
  Test threw exception
  Expression: MOI.get(model, MOI.ObjectiveBound()) >= 4.0
  MethodError: no method matching CPLEX.CplexError(::Ptr{Nothing}, ::Int32)
  Closest candidates are:
    CPLEX.CplexError(!Matched::CPLEX.Env, ::Integer) at C:\Users\angeloaliano\.julia\packages\CPLEX\mo9kV\src\cpx_env.jl:90
  Stacktrace:
   [1] get_best_bound(::CPLEX.Model) at C:\Users\angeloaliano\.julia\packages\CPLEX\mo9kV\src\cpx_callbacks.jl:5
   [2] get_objective_bound(::CPLEX.Optimizer) at C:\Users\angeloaliano\.julia\packages\CPLEX\mo9kV\src\MOI_wrapper.jl:306
   [3] get at C:\Users\angeloaliano\.julia\packages\LinQuadOptInterface\ZMx9f\src\solve.jl:240 [inlined]
   [4] macro expansion at C:\Users\angeloaliano\.julia\packages\MathOptInterface\C3lip\src\Test\UnitTests\solve.jl:77 [inlined]
   [5] macro expansion at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\Test\src\Test.jl:1083 [inlined]
   [6] solve_objbound_edge_cases(::CPLEX.Optimizer, ::MathOptInterface.Test.TestConfig) at C:\Users\angeloaliano\.julia\packages\MathOptInterface\C3lip\src\Test\UnitTests\solve.jl:64
Test Summary:                                  | Pass  Fail  Error  Total
MathOptInterface                               |  913     2      2    917
  MOI_wrapper.jl                               |  913     2      2    917
    Unit Tests                                 |  330     2      2    334
      solve_duplicate_terms_obj                |    9                   9
      solve_with_lowerbound                    |   11                  11
      solve_blank_obj                          |    8                   8
      delete_variables                         |    4                   4
      min_sense                                |    3                   3
      add_variables                            |    3                   3
      solve_affine_greaterthan                 |    8                   8
      feasibility_sense                        |    3                   3
      add_variable                             |    3                   3
      solve_with_upperbound                    |   11                  11
      getvariable                              |    2                   2
      solve_singlevariable_obj                 |    9                   9
      solve_affine_equalto                     |    8                   8
      max_sense                                |    3                   3
      solve_duplicate_terms_vector_affine      |    8                   8
      getconstraint                            |    7                   7
      get_objective_function                   |    5                   5
      solve_affine_lessthan                    |    8                   8
      solve_objbound_edge_cases                |   20     2      2     24
        Min IP with constant                   |    5     1             6
        Max IP with constant                   |    5     1             6
        Min LP with constant                   |    5            1      6
        Max LP with constant                   |    5            1      6
      solve_constant_obj                       |    9                   9
      solve_duplicate_terms_scalar_affine      |    8                   8
      solve_affine_deletion_edge_cases         |   24                  24
      variablenames                            |    5                   5
      solve_integer_edge_cases                 |   20                  20
      delete_variable                          |    4                   4
      solve_affine_interval                    |    8                   8
      solve_set_singlevariable_lessthan        |   17                  17
      solve_coef_scalaraffine_lessthan         |   16                  16
      solve_coef_scalar_objective              |    8                   8
      solve_const_scalar_objective             |    8                   8
      solve_transform_singlevariable_lessthan  |   18                  18
      solve_multirow_vectoraffine_nonpos       |   12                  12
      solve_const_vectoraffine_nonpos          |   14                  14
      delete_variable_with_single_variable_obj |    9                   9
      solve_set_scalaraffine_lessthan          |   17                  17
    Linear tests                               |  359                 359
    Integer Linear tests                       |   99                  99
    ModelLike tests                            |  115                 115
    Env                                        |   10                  10
ERROR: LoadError: Some tests did not pass: 913 passed, 2 failed, 2 errored, 0 broken.
in expression starting at C:\Users\angeloaliano\.julia\packages\CPLEX\mo9kV\test\runtests.jl:7
ERROR: Package CPLEX errored during testing

@ghost
Copy link
Author

ghost commented Apr 1, 2019

The print of erros are below:

Error1
Error2
Error3
Error4
Error5

@ghost
Copy link
Author

ghost commented Apr 1, 2019 via email

@odow odow added the Wrapper: MathOptInterface Relates to the MathOptInterface API label Oct 30, 2019
@odow odow mentioned this issue Nov 4, 2019
16 tasks
@odow odow closed this as completed in #261 Nov 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Wrapper: MathOptInterface Relates to the MathOptInterface API
Development

Successfully merging a pull request may close this issue.

2 participants