Skip to content

Commit 8742ceb

Browse files
authored
Fix Bridges.runtests when model has no variable (#2499)
1 parent 27e0e7d commit 8742ceb

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Bridges/Bridges.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,10 @@ function runtests(
283283
Test.@test all(isnothing, MOI.get(model, attr, x))
284284
primal_start = fill(constraint_start, length(x))
285285
MOI.set(model, attr, x, primal_start)
286-
Test.@test MOI.get(model, attr, x) primal_start
286+
if !isempty(x)
287+
# ≈ does not work if x is empty because the return of get is Any[]
288+
Test.@test MOI.get(model, attr, x) primal_start
289+
end
287290
end
288291
# Test ConstraintPrimalStart and ConstraintDualStart
289292
for (F, S) in MOI.get(model, MOI.ListOfConstraintTypesPresent())

test/Bridges/Constraint/flip_sign.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,19 @@ function test_runtests()
436436
VectorNonlinearFunction([-(2.1 * x - 1.0)]) in Nonnegatives(1)
437437
""",
438438
)
439+
MOI.Bridges.runtests(
440+
MOI.Bridges.Constraint.GreaterToLessBridge,
441+
model -> MOI.add_constraint(
442+
model,
443+
zero(MOI.ScalarAffineFunction{Float64}),
444+
MOI.GreaterThan(1.0),
445+
),
446+
model -> MOI.add_constraint(
447+
model,
448+
zero(MOI.ScalarAffineFunction{Float64}),
449+
MOI.LessThan(-1.0),
450+
),
451+
)
439452
return
440453
end
441454

0 commit comments

Comments
 (0)