From 9268dd2115dfd3ee852b9862552a36fbf369b552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Thu, 19 Oct 2023 10:36:21 +0200 Subject: [PATCH 1/2] First constraint index to 1 instead of 2 --- src/MOI_wrapper/MOI_wrapper.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MOI_wrapper/MOI_wrapper.jl b/src/MOI_wrapper/MOI_wrapper.jl index 4a97ea9..8961c0b 100644 --- a/src/MOI_wrapper/MOI_wrapper.jl +++ b/src/MOI_wrapper/MOI_wrapper.jl @@ -338,7 +338,7 @@ mutable struct Optimizer <: MOI.AbstractOptimizer _INVERSE_HASH, ) model.next_column = 1 - model.last_constraint_index = 1 + model.last_constraint_index = 0 model.columns_deleted_since_last_update = Int[] model.affine_constraint_info = Dict{Int,_ConstraintInfo}() model.quadratic_constraint_info = Dict{Int,_ConstraintInfo}() From 1a2fe425fa571d2963ffb67500381e72e2d57e30 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 20 Oct 2023 10:58:01 +1100 Subject: [PATCH 2/2] Add test --- test/MOI/MOI_wrapper.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/MOI/MOI_wrapper.jl b/test/MOI/MOI_wrapper.jl index 0b18296..9bb0d59 100644 --- a/test/MOI/MOI_wrapper.jl +++ b/test/MOI/MOI_wrapper.jl @@ -870,6 +870,14 @@ function test_attribute_TimeLimitSec() return end +function test_last_constraint_index() + model = Gurobi.Optimizer(GRB_ENV) + x = MOI.add_variable(model) + c = MOI.add_constraint(model, 1.0 * x, MOI.GreaterThan(1.0)) + @test c.value == 1 + return +end + end TestMOIWrapper.runtests()