jump-dev / ParametricOptInterface.jl

Extension for dealing with parameters
MIT License
37 stars 7 forks source link

MOI.get broken for parameter * variable constraints #150

Closed odow closed 4 months ago

odow commented 4 months ago
julia> using JuMP

julia> import Gurobi

julia> import ParametricOptInterface as POI

julia> model = Model(() -> POI.Optimizer(Gurobi.Optimizer()))
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: Parametric Optimizer with Gurobi attached

julia> @variable(model, x)
x

julia> @variable(model, p in Parameter(2.0))
p

julia> @constraint(model, c, p * x <= 10)
c : p*x ≤ 10

julia> optimize!(model)
Gurobi Optimizer version 11.0.2 build v11.0.2rc0 (mac64[x86] - Darwin 23.5.0 23F79)

CPU model: Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads

Optimize a model with 1 rows, 1 columns and 1 nonzeros
Model fingerprint: 0xc227184b
Coefficient statistics:
  Matrix range     [2e+00, 2e+00]
  Objective range  [0e+00, 0e+00]
  Bounds range     [0e+00, 0e+00]
  RHS range        [1e+01, 1e+01]
Presolve removed 1 rows and 1 columns
Presolve time: 0.00s
Presolve: All rows and columns removed
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0    0.0000000e+00   0.000000e+00   0.000000e+00      0s

Solved in 0 iterations and 0.00 seconds (0.00 work units)
Optimal objective  0.000000000e+00

User-callback calls 31, time in user-callback 0.00 sec

julia> value(c)
c = MathOptInterface.ConstraintIndex{MathOptInterface.ScalarQuadraticFunction{Float64}, MathOptInterface.LessThan{Float64}}(1)
ERROR: The index MathOptInterface.ConstraintIndex{MathOptInterface.ScalarQuadraticFunction{Float64}, MathOptInterface.LessThan{Float64}}(1) is invalid. Note that an index becomes invalid after it has been deleted.
Stacktrace:
  [1] _info
    @ ~/.julia/packages/Gurobi/uP4zR/src/MOI_wrapper/MOI_wrapper.jl:2342 [inlined]
  [2] get(model::Gurobi.Optimizer, attr::MathOptInterface.ConstraintPrimal, c::MathOptInterface.ConstraintIndex{…})
    @ Gurobi ~/.julia/packages/Gurobi/uP4zR/src/MOI_wrapper/MOI_wrapper.jl:3019
  [3] get
    @ ~/.julia/dev/ParametricOptInterface/src/MOI_wrapper.jl:1110 [inlined]
  [4] get