Skip to content
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

Error when trying to query objective value with CPLEX #2047

Closed
bcdandurand opened this issue Aug 26, 2019 · 2 comments · Fixed by JuliaRegistries/General#2971
Closed

Error when trying to query objective value with CPLEX #2047

bcdandurand opened this issue Aug 26, 2019 · 2 comments · Fixed by JuliaRegistries/General#2971

Comments

@bcdandurand
Copy link

bcdandurand commented Aug 26, 2019

I'm using the current version of JuMP, v0.20.0

I have the following simple code snippet where both CPLEX and Ipopt can be used:

 using JuMP
 using CPLEX, Ipopt

  mTest = Model(with_optimizer(CPLEX.Optimizer))
  #mTest = Model(with_optimizer(Ipopt.Optimizer))
  @variable(mTest, x)
  @variable(mTest, y)
  @objective(mTest, Min, (x-3)^2 + (y+2)^2)
  println(mTest)
  optimize!(mTest)
  println("Status: ",JuMP.termination_status(mTest))
  println("(x,y)=",JuMP.value(x)," ",JuMP.value(y))
  println("obj val: ",JuMP.objective_value(mTest))
  println("It works!")

When I run the code, it computes the correct optimal solution, but then I get the error when querying the objective value. The code works fine when using Ipopt, so I'm not sure if this is an issue with JuMP or with CPLEX.jl

Status: OPTIMAL
(x,y)=2.9999999996524593 -2.0000000000011937
ERROR: LoadError: type ObjectiveValue has no field resultindex
Stacktrace:
[1] getproperty(::Any, ::Symbol) at ./Base.jl:20
[2] get(::CPLEX.Optimizer, ::MathOptInterface.ObjectiveValue) at /homes/bcdandurand/.julia/packages/LinQuadOptInterface/ZMx9f/src/solve.jl:107
[3] get(::MathOptInterface.Bridges.LazyBridgeOptimizer{CPLEX.Optimizer}, ::MathOptInterface.ObjectiveValue) at /homes/bcdandurand/.julia/packages/MathOptInterface/016Ol/src/Bridges/bridge_optimizer.jl:444
[4] get(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, ::MathOptInterface.ObjectiveValue) at /homes/bcdandurand/.julia/packages/MathOptInterface/016Ol/src/Utilities/cachingoptimizer.jl:449
[5] _moi_get_result(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, ::MathOptInterface.ObjectiveValue) at /homes/bcdandurand/.julia/packages/JuMP/iGamg/src/JuMP.jl:605
[6] get(::Model, ::MathOptInterface.ObjectiveValue) at /homes/bcdandurand/.julia/packages/JuMP/iGamg/src/JuMP.jl:618
[7] objective_value(::Model) at /homes/bcdandurand/.julia/packages/JuMP/iGamg/src/objective.jl:25
[8] top-level scope at /nfs2/bcdandurand/OPF-VID/test_opt.jl:14
[9] include at ./boot.jl:328 [inlined]
[10] include_relative(::Module, ::String) at ./loading.jl:1094
[11] include(::Module, ::String) at ./Base.jl:31
[12] exec_options(::Base.JLOptions) at ./client.jl:295
[13] _start() at ./client.jl:464
in expression starting at /nfs2/bcdandurand/OPF-VID/test_opt.jl:14

@blegat
Copy link
Member

blegat commented Aug 26, 2019

CPLEX has not been updated to MOI v0.9 yet, which is the version of the interface used by JuMP, it is currently been updated here: jump-dev/CPLEX.jl#250

@mlubin
Copy link
Member

mlubin commented Aug 27, 2019

The bug is that Pkg allowed you to install CPLEX and JuMP 0.20. This will be fixed by JuliaRegistries/General#2971.

StefanKarpinski pushed a commit to JuliaRegistries/General that referenced this issue Aug 27, 2019
LinQuadOptInterface is not compatible with MathOptInterface > 0.8.x. This is stated in the original [REQUIRE](https://github.com/JuliaOpt/LinQuadOptInterface.jl/blob/148334e6b74c37f2108ff8dc92169d18e99584a7/REQUIRE).

Closes jump-dev/JuMP.jl#2047.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants