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

Add test for issue #187 #191

Merged
merged 2 commits into from
Mar 2, 2022
Merged
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
37 changes: 37 additions & 0 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,43 @@ function test_PrimalStatus()
return
end

function test_issue_187()
if Sys.iswindows() || Sys.islinux()
# This test segfaults on Windows and Linux
@test_broken 1 == 2
return
end
model = MOI.Utilities.CachingOptimizer(
MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()),
MOI.instantiate(Cbc.Optimizer; with_bridge_type = Float64),
)
MOI.set(model, MOI.Silent(), true)
x = MOI.add_variables(model, 2)
MOI.add_constraint.(model, x, MOI.ZeroOne())
MOI.set.(model, MOI.VariablePrimalStart(), x, 0.0)
y = MOI.add_variables(model, 2)
MOI.add_constraint.(model, y, MOI.ZeroOne())

MOI.add_constraint(
model,
MOI.Utilities.operate(vcat, Float64, x[1], 1.0 * y[1]),
MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.EqualTo(1.0)),
)
MOI.add_constraint(
model,
MOI.Utilities.operate(vcat, Float64, x[2], 1.0 * y[1]),
MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.EqualTo(0.0)),
)
MOI.set.(model, MOI.VariablePrimalStart(), y, 0.0)
MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE)
f = MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(1.0, x), 0.0)
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
MOI.optimize!(model)
@test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMAL
@test ≈(sum(MOI.get(model, MOI.VariablePrimal(), x)), 1.0, atol = 1e-4)
return
end

# The test_linear_SOS1_integration test with the additional requirement that all
# variables are integer.
function test_SOS1()
Expand Down