Skip to content

Commit

Permalink
Fix Bridges.runtests when model has no variable (#2499)
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat authored May 13, 2024
1 parent 27e0e7d commit 8742ceb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Bridges/Bridges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@ function runtests(
Test.@test all(isnothing, MOI.get(model, attr, x))
primal_start = fill(constraint_start, length(x))
MOI.set(model, attr, x, primal_start)
Test.@test MOI.get(model, attr, x) primal_start
if !isempty(x)
# ≈ does not work if x is empty because the return of get is Any[]
Test.@test MOI.get(model, attr, x) primal_start
end
end
# Test ConstraintPrimalStart and ConstraintDualStart
for (F, S) in MOI.get(model, MOI.ListOfConstraintTypesPresent())
Expand Down
13 changes: 13 additions & 0 deletions test/Bridges/Constraint/flip_sign.jl
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,19 @@ function test_runtests()
VectorNonlinearFunction([-(2.1 * x - 1.0)]) in Nonnegatives(1)
""",
)
MOI.Bridges.runtests(
MOI.Bridges.Constraint.GreaterToLessBridge,
model -> MOI.add_constraint(
model,
zero(MOI.ScalarAffineFunction{Float64}),
MOI.GreaterThan(1.0),
),
model -> MOI.add_constraint(
model,
zero(MOI.ScalarAffineFunction{Float64}),
MOI.LessThan(-1.0),
),
)
return
end

Expand Down

0 comments on commit 8742ceb

Please sign in to comment.