|
378 | 378 | objective_type_test(convert(MOI.ScalarQuadraticFunction{Float64}, f)) |
379 | 379 | end |
380 | 380 |
|
| 381 | +@testset "Conflicting SingleVariable constraints" begin |
| 382 | + @testset "ZeroOne" begin |
| 383 | + model = LQOI.MockLinQuadOptimizer() |
| 384 | + x = MOI.add_variable(model) |
| 385 | + MOI.add_constraint(model, MOI.SingleVariable(x), MOI.ZeroOne()) |
| 386 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Interval(2.0, 3.0)) |
| 387 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Integer()) |
| 388 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Semiinteger(2.0, 3.0)) |
| 389 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Semicontinuous(2.0, 3.0)) |
| 390 | + end |
| 391 | + @testset "Integer" begin |
| 392 | + model = LQOI.MockLinQuadOptimizer() |
| 393 | + x = MOI.add_variable(model) |
| 394 | + MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Integer()) |
| 395 | + MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Interval(2.0, 3.0)) |
| 396 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.ZeroOne()) |
| 397 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Semiinteger(2.0, 3.0)) |
| 398 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Semicontinuous(2.0, 3.0)) |
| 399 | + end |
| 400 | + @testset "Semiinteger" begin |
| 401 | + model = LQOI.MockLinQuadOptimizer() |
| 402 | + x = MOI.add_variable(model) |
| 403 | + MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Semiinteger(2.0, 3.0)) |
| 404 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Interval(2.0, 3.0)) |
| 405 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.ZeroOne()) |
| 406 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Integer()) |
| 407 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Semicontinuous(2.0, 3.0)) |
| 408 | + end |
| 409 | + @testset "Semicontinuous" begin |
| 410 | + model = LQOI.MockLinQuadOptimizer() |
| 411 | + x = MOI.add_variable(model) |
| 412 | + MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Semicontinuous(2.0, 3.0)) |
| 413 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Interval(2.0, 3.0)) |
| 414 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.ZeroOne()) |
| 415 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Integer()) |
| 416 | + @test_throws Exception MOI.add_constraint(model, MOI.SingleVariable(x), MOI.Semiinteger(2.0, 3.0)) |
| 417 | + end |
| 418 | +end |
| 419 | + |
381 | 420 | @testset "SemiXXX variables" begin |
382 | 421 | @testset "Semiinteger" begin |
383 | 422 | model = LQOI.MockLinQuadOptimizer() |
|
0 commit comments