Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bridges.runtests when model has no variable #2499

Merged
merged 7 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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)

Check warning on line 286 in src/Bridges/Bridges.jl

View check run for this annotation

Codecov / codecov/patch

src/Bridges/Bridges.jl#L286

Added line #L286 was not covered by tests
# ≈ does not work if x is empty because the return of get is Any[]
Test.@test MOI.get(model, attr, x) ≈ primal_start

Check warning on line 288 in src/Bridges/Bridges.jl

View check run for this annotation

Codecov / codecov/patch

src/Bridges/Bridges.jl#L288

Added line #L288 was not covered by tests
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
Loading