Skip to content

Commit

Permalink
Merge c89bf3d into 921f84d
Browse files Browse the repository at this point in the history
  • Loading branch information
matbesancon committed Feb 28, 2020
2 parents 921f84d + c89bf3d commit 6a87628
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Expand Up @@ -9,7 +9,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
JuMP = "0.20"
JuMP = "0.21"
julia = "1"

[extras]
Expand Down
30 changes: 15 additions & 15 deletions test/runtests.jl
Expand Up @@ -21,7 +21,7 @@ end

@testset "test basic problem" begin
bp = test_bp()
(m, x, y, λ, _) = build_blp_model(bp, with_optimizer(Cbc.Optimizer, LogLevel = 0))
(m, x, y, λ, _) = build_blp_model(bp, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0))
JuMP.optimize!(m)
@test termination_status(m) === MOI.OPTIMAL
xv = JuMP.value.(x)
Expand All @@ -33,7 +33,7 @@ end
@testset "Integrality is registered" begin
bp = test_bp()
push!(bp.Jx, 2) # second useless variable is integer
(m, x, y, λ, _) = build_blp_model(bp, with_optimizer(Cbc.Optimizer, LogLevel = 0))
(m, x, y, λ, _) = build_blp_model(bp, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0))
# @test JuMP.getcategory(x[2]) == :Int
# @test JuMP.getcategory(x[1]) == :Cont
# @test JuMP.getcategory(y[1]) == :Cont
Expand All @@ -58,7 +58,7 @@ end
G, H, q,
d, A, B, b
)
(m, x, y, λ, _) = build_blp_model(prob, with_optimizer(Cbc.Optimizer, LogLevel = 0))
(m, x, y, λ, _) = build_blp_model(prob, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0))
JuMP.optimize!(m)
@test termination_status(m) === MOI.OPTIMAL
@test JuMP.value(x[1]) 8
Expand All @@ -73,7 +73,7 @@ end
G, H, q,
d, A, B, b
)
(m, x, y, λ, _) = build_blp_model(prob, with_optimizer(Cbc.Optimizer, LogLevel = 0))
(m, x, y, λ, _) = build_blp_model(prob, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0))
JuMP.optimize!(m)
@test termination_status(m) === MOI.OPTIMAL
@test JuMP.value(x[1]) 6
Expand Down Expand Up @@ -109,7 +109,7 @@ end
set_lower_bound(prob, BilevelOptimization.lower, 2, 0.)
setupperbound(prob, BilevelOptimization.lower, 2, 2.)
@test size(prob.B) == (prob.ml,prob.nl)
(m, x, y, λ, _) = build_blp_model(prob, with_optimizer(Cbc.Optimizer, LogLevel = 0))
(m, x, y, λ, _) = build_blp_model(prob, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0))
JuMP.optimize!(m)
@test termination_status(m) === MOI.OPTIMAL
@test all(JuMP.value.(x) .≈ (-1.,-1.))
Expand Down Expand Up @@ -146,7 +146,7 @@ end
G, H, q,
d, A, B, b, Jx, ylowerbound = false
)
(m, x, y, λ, _) = build_blp_model(intprob, with_optimizer(Cbc.Optimizer, LogLevel = 0))
(m, x, y, λ, _) = build_blp_model(intprob, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0))
JuMP.optimize!(m)
@test termination_status(m) === MOI.OPTIMAL
@test all(JuMP.value.(x) .≈ (2.,2.))
Expand All @@ -161,7 +161,7 @@ end
G, H, q,
d, A, B, b, Jx
)
(m, x, y, λ, _) = build_blp_model(intprob, with_optimizer(Cbc.Optimizer, LogLevel = 0))
(m, x, y, λ, _) = build_blp_model(intprob, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0))
JuMP.optimize!(m)
@test termination_status(m) === MOI.OPTIMAL
@test all(JuMP.value.(x) .≈ (2.,2.))
Expand Down Expand Up @@ -220,7 +220,7 @@ end

@testset "Bilevel flow JuMP model" begin
bfp = test_bflow()
(m, r, y, f, λ) = build_blp_model(bfp, with_optimizer(Cbc.Optimizer, LogLevel = 0))
(m, r, y, f, λ) = build_blp_model(bfp, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0))
JuMP.optimize!(m)
@test termination_status(m) === MOI.OPTIMAL
@test JuMP.objective_value(m) 6.
Expand All @@ -239,18 +239,18 @@ end

@testset "Basic problem with specified methods" begin
bp = test_bp()
(m, x, y, λ) = build_blp_model(bp, with_optimizer(Cbc.Optimizer, LogLevel = 0), comp_method = SOS1Complementarity())
(m, x, y, λ) = build_blp_model(bp, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0), comp_method = SOS1Complementarity())
JuMP.optimize!(m)
@test termination_status(m) === MOI.OPTIMAL
xv = JuMP.value.(x)
yv = JuMP.value.(y)
@test xv[1] 0.0
@test yv[1] 1.0
(m, _, _, _) = build_blp_model(bp, with_optimizer(Cbc.Optimizer, LogLevel = 0), comp_method = SOS1Complementarity())
(m, _, _, _) = build_blp_model(bp, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0), comp_method = SOS1Complementarity())
JuMP.optimize!(m)
@test termination_status(m) === MOI.OPTIMAL
# arbitrary big-enough bounds
(m, x, y, λ) = build_blp_model(bp, with_optimizer(Cbc.Optimizer, LogLevel = 0), comp_method = BoundComplementarity(100.,100.))
(m, x, y, λ) = build_blp_model(bp, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0), comp_method = BoundComplementarity(100.,100.))
JuMP.optimize!(m)
@test termination_status(m) === MOI.OPTIMAL
xv = JuMP.value.(x)
Expand All @@ -261,7 +261,7 @@ end

@testset "Bilevel flow big-M bounds" begin
bfp = test_bflow()
(m, r, y, f, λ) = build_blp_model(bfp, with_optimizer(Cbc.Optimizer, LogLevel = 0), comp_method = BoundComplementarity(100., 100.))
(m, r, y, f, λ) = build_blp_model(bfp, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0), comp_method = BoundComplementarity(100., 100.))
JuMP.optimize!(m)
@test termination_status(m) === MOI.OPTIMAL
@test JuMP.objective_value(m) 6.
Expand All @@ -275,7 +275,7 @@ end
@testset "Bilevel flow big-M vector bounds" begin
bfp = test_bflow()
bounds_method = BoundComplementarity(10 .* ones(19), 30.)
(m, r, y, f, λ) = build_blp_model(bfp, with_optimizer(Cbc.Optimizer), comp_method = bounds_method)
(m, r, y, f, λ) = build_blp_model(bfp, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0), comp_method = bounds_method)
JuMP.optimize!(m)
@test termination_status(m) === MOI.OPTIMAL
@test JuMP.objective_value(m) 6.
Expand All @@ -285,7 +285,7 @@ end
end
end
bounds_method = BoundComplementarity(10., 10 .* ones(19))
(m, r, y, f, λ) = build_blp_model(bfp, with_optimizer(Cbc.Optimizer, LogLevel = 0), comp_method = bounds_method)
(m, r, y, f, λ) = build_blp_model(bfp, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0), comp_method = bounds_method)
JuMP.optimize!(m)
@test termination_status(m) === MOI.OPTIMAL
@test JuMP.objective_value(m) 6.
Expand All @@ -298,7 +298,7 @@ end

@testset "Bilevel flow big-M infeasible" begin
bfp = test_bflow()
(m, r, y, f, λ) = build_blp_model(bfp, with_optimizer(Cbc.Optimizer, LogLevel = 0), comp_method = BoundComplementarity(0.1, 0.1))
(m, r, y, f, λ) = build_blp_model(bfp, optimizer_with_attributes(Cbc.Optimizer, "LogLevel" => 0), comp_method = BoundComplementarity(0.1, 0.1))
JuMP.optimize!(m)
@test termination_status(m) === MOI.INFEASIBLE
end

0 comments on commit 6a87628

Please sign in to comment.