-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
I still don't know where the error is.
Here is what I know:
- The seemingly inoffensive(we know they are never inoffensive) update in POI: Update POI DiffOpt.jl#316
Led to a fail in MOI tests in DiffOpt:
test_conic_linear_VectorOfVariables_2: Error During Test at /home/runner/.julia/packages/MathOptInterface/zq9bo/src/Test/Test.jl:264
Got exception outside of a @test
KeyError: key MOI.VariableIndex(4) not found
Stacktrace:
[1] getindex(c::MathOptInterface.Utilities.CleverDicts.CleverDict{MathOptInterface.VariableIndex, MathOptInterface.VariableIndex, typeof(MathOptInterface.Utilities.CleverDicts.key_to_index), typeof(MathOptInterface.Utilities.CleverDicts.index_to_key)}, key::MathOptInterface.VariableIndex)
@ MathOptInterface.Utilities.CleverDicts ~/.julia/packages/MathOptInterface/zq9bo/src/Utilities/CleverDicts.jl:164
[2] getindex
@ ~/.julia/packages/MathOptInterface/zq9bo/src/Utilities/copy/index_map.jl:64 [inlined]
[3] _extract_row_data(dest::HiGHS.Optimizer, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, mapping::MathOptInterface.Utilities.IndexMap, rowlower::Vector{Float64}, rowupper::Vector{Float64}, I::Vector{Int32}, J::Vector{Int32}, V::Vector{Float64}, ::Type{MathOptInterface.EqualTo{Float64}})
@ HiGHS ~/.julia/packages/HiGHS/umjNf/src/MOI_wrapper.jl:2997
[4] copy_to(dest::HiGHS.Optimizer, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}})
@ HiGHS ~/.julia/packages/HiGHS/umjNf/src/MOI_wrapper.jl:3065I reduced the test to:
using Test
import MathOptInterface as MOI
import DiffOpt
import HiGHS
model = DiffOpt.diff_optimizer(HiGHS.Optimizer)
MOI.set(model, MOI.Silent(), true)
T = Float64
x = MOI.add_variable(model)
@test MOI.get(model, MOI.NumberOfVariables()) == 1
ys, vc = MOI.add_constrained_variables(model, MOI.Nonpositives(1))
y = ys[1]
@test MOI.get(model, MOI.NumberOfVariables()) == 2
z, s = MOI.add_variables(model, 2)
@test MOI.get(model, MOI.NumberOfVariables()) == 4
MOI.set(
model,
MOI.ObjectiveFunction{MOI.ScalarAffineFunction{T}}(),
MOI.ScalarAffineFunction(
MOI.ScalarAffineTerm.(T[3, 2, -4], [x, y, z]),
T(0),
),
)
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
c = MOI.add_constraint(
model,
MOI.VectorAffineFunction(
MOI.VectorAffineTerm.(
[1, 1, 2, 3, 3],
MOI.ScalarAffineTerm.(T[1, -1, 1, 1, 1], [x, s, y, x, z]),
),
T[4, 3, -12],
),
MOI.Zeros(3),
)
vz = MOI.add_constraint(model, [z], MOI.Nonnegatives(1))
vov = MOI.VectorOfVariables([s])
vs = MOI.add_constraint(model, vov, MOI.Zeros(1))
@test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMIZE_NOT_CALLED
MOI.optimize!(model)
And the same error is trigged.
Inpective the innermost CachingOptimizer we get:
julia> model.optimizer.optimizer.optimizer.model
MOIU.CachingOptimizer
├ state: EMPTY_OPTIMIZER
├ mode: AUTOMATIC
├ model_cache: MOIU.UniversalFallback{MOIU.Model{Float64}}
│ ├ ObjectiveSense: MIN_SENSE
│ ├ ObjectiveFunctionType: MOI.ScalarAffineFunction{Float64}
│ ├ NumberOfVariables: 3
│ └ NumberOfConstraints: 5
│ ├ MOI.ScalarAffineFunction{Float64} in MOI.EqualTo{Float64}: 3
│ ├ MOI.VariableIndex in MOI.GreaterThan{Float64}: 1
│ └ MOI.VariableIndex in MOI.LessThan{Float64}: 1
└ optimizer: A HiGHS model with 0 columns and 0 rows.
Where there are only 3 variables:
julia> model.optimizer.optimizer.optimizer.model.model_cache.model.variables
MathOptInterface.Utilities.VariablesContainer{Float64}(UInt16[0x0000, 0x0004, 0x0002], [-Inf, -Inf, 0.0], [Inf, 0.0, Inf])but the first of the affine constraints contains a 4th variable!
julia> model.optimizer.optimizer.optimizer.model.model_cache.model.constraints.moi_scalaraffinefunction.moi_equalto.constraints
MathOptInterface.Utilities.CleverDicts.CleverDict{MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}, Tuple{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}, typeof(MathOptInterface.Utilities.CleverDicts.key_to_index), typeof(MathOptInterface.Utilities.CleverDicts.index_to_key)} with 3 entries:
ConstraintIndex{ScalarAffineFunction{Float64}, EqualTo{Float64}}(1) => (0.0 + 1.0 MOI.VariableIndex(1) - 1.0 MOI.VariableIndex(4), EqualTo{Float64}(-4.0))
ConstraintIndex{ScalarAffineFunction{Float64}, EqualTo{Float64}}(2) => (0.0 + 1.0 MOI.VariableIndex(2), EqualTo{Float64}(-3.0))
ConstraintIndex{ScalarAffineFunction{Float64}, EqualTo{Float64}}(3) => (0.0 + 1.0 MOI.VariableIndex(1) + 1.0 MOI.VariableIndex(3), EqualTo{Float64}(12.0))Metadata
Metadata
Assignees
Labels
No labels