Skip to content

Commit

Permalink
Add test and fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Dec 20, 2023
1 parent 623ac12 commit 947b8d9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Bridges/Variable/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ function add_keys_for_bridge(
end

Check warning on line 417 in src/Bridges/Variable/map.jl

View check run for this annotation

Codecov / codecov/patch

src/Bridges/Variable/map.jl#L415-L417

Added lines #L415 - L417 were not covered by tests
push!(map.vector_of_variables_map, -bridge_index)
push!(map.vector_of_variables_length, MOI.dimension(set))
push!(map.info, -length(map.vector_of_variables_length))
constraint_index = -length(map.vector_of_variables_map)
push!(map.info, constraint_index)
push!(map.index_in_vector, 1)
push!(map.bridges, nothing)
push!(map.sets, typeof(set))
Expand Down Expand Up @@ -446,8 +447,7 @@ function add_keys_for_bridge(
end
end
end
return variables,
MOI.ConstraintIndex{F,S}(-length(map.vector_of_variables_map))
return variables, MOI.ConstraintIndex{F,S}(constraint_index)
end

"""
Expand Down
18 changes: 17 additions & 1 deletion test/Bridges/lazy_bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ function test_MOI_runtests_GeometricSDPAModel()
return
end

function test_index_conflict()
function test_index_constraint_conflict()
optimizer = StandardSDPAModel{Float64}()
model = MOI.Bridges.full_bridge_optimizer(optimizer, Float64)
x, cx = MOI.add_constrained_variables(model, MOI.Nonpositives(1))
Expand All @@ -348,6 +348,22 @@ function test_index_conflict()
@test c != b2.slack_in_set
end

function test_index_variable_conflict()
optimizer = StandardSDPAModel{Float64}()
model = MOI.Bridges.full_bridge_optimizer(optimizer, Float64)
set = MOI.SecondOrderCone(3)
x = MOI.add_variables(model, 3)
c = MOI.add_constraint(model, MOI.VectorOfVariables(x), set)
@test MOI.is_valid(model, c)
y, cy = MOI.add_constrained_variables(model, set)
@test MOI.is_valid(model, cy)
@test cy != c
z, cz = MOI.add_constrained_variables(model, set)
@test MOI.is_valid(model, cz)
@test cz != c
end


function test_show_SPDA()
model = StandardSDPAModel{Float64}()
model_str = sprint(MOI.Utilities.print_with_acronym, string(typeof(model)))
Expand Down

0 comments on commit 947b8d9

Please sign in to comment.