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

reduce log + show functions #82

Merged
merged 1 commit into from
May 21, 2019
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
87 changes: 87 additions & 0 deletions test/full_instances_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
function full_instances_tests()
@testset "play gap" begin
data = CLD.GeneralizedAssignment.data("play2.txt")

coluna = JuMP.with_optimizer(Coluna.Optimizer,# #params = params,
master_factory = with_optimizer(GLPK.Optimizer),
pricing_factory = with_optimizer(GLPK.Optimizer))

problem, x, dec = CLD.GeneralizedAssignment.model(data, coluna)

JuMP.optimize!(problem)
@test abs(JuMP.objective_value(problem) - 75.0) <= 0.00001
@test CLD.GeneralizedAssignment.print_and_check_sol(data, problem, x)
end

@testset "gap - JuMP/MOI modeling" begin
data = CLD.GeneralizedAssignment.data("smallgap3.txt")

coluna = JuMP.with_optimizer(Coluna.Optimizer,# #params = params,
master_factory = with_optimizer(GLPK.Optimizer),
pricing_factory = with_optimizer(GLPK.Optimizer))

problem, x, dec = CLD.GeneralizedAssignment.model(data, coluna)

JuMP.optimize!(problem)
@test abs(JuMP.objective_value(problem) - 438.0) <= 0.00001
@test CLD.GeneralizedAssignment.print_and_check_sol(data, problem, x)
end

@testset "gap with penalties - pure master variables" begin
data = CLD.GeneralizedAssignment.data("smallgap3.txt")

coluna = JuMP.with_optimizer(Coluna.Optimizer,# #params = params,
master_factory = with_optimizer(GLPK.Optimizer),
pricing_factory = with_optimizer(GLPK.Optimizer)
)

problem, x, y, dec = CLD.GeneralizedAssignment.model_with_penalties(data, coluna)
JuMP.optimize!(problem)
@test abs(JuMP.objective_value(problem) - 416.4) <= 0.00001
end

@testset "gap with maximisation objective function" begin
data = CLD.GeneralizedAssignment.data("smallgap3.txt")

coluna = JuMP.with_optimizer(Coluna.Optimizer,# #params = params,
master_factory = with_optimizer(GLPK.Optimizer),
pricing_factory = with_optimizer(GLPK.Optimizer)
)

problem, x, dec = CLD.GeneralizedAssignment.model_max(data, coluna)
JuMP.optimize!(problem)
@test abs(JuMP.objective_value(problem) - 580.0) <= 0.00001
end

# @testset "gap BIG instance" begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you keep this test if it is commented?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for us to test the big instance from time to time without deploying it

# data = CLD.GeneralizedAssignment.data("gapC-5-100.txt")

# coluna = JuMP.with_optimizer(Coluna.Optimizer,# #params = params,
# master_factory = with_optimizer(GLPK.Optimizer),
# pricing_factory = with_optimizer(GLPK.Optimizer)
# )

# problem, x, dec = CLD.GeneralizedAssignment.model(data, coluna)
# JuMP.optimize!(problem)
# @test abs(JuMP.objective_value(problem) - 1931.0) <= 0.00001
# @test CLD.GeneralizedAssignment.print_and_check_sol(data, problem, x)
# end

# To redirect logging output
io = IOBuffer()
global_logger(ConsoleLogger(io, LogLevel(-4)))

@testset "play gap" begin
data = CLD.GeneralizedAssignment.data("play2.txt")

coluna = JuMP.with_optimizer(Coluna.Optimizer,# #params = params,
master_factory = with_optimizer(GLPK.Optimizer),
pricing_factory = with_optimizer(GLPK.Optimizer)
)

problem, x, dec = CLD.GeneralizedAssignment.model(data, coluna)
JuMP.optimize!(problem)
@test abs(JuMP.objective_value(problem) - 75.0) <= 0.00001
@test CLD.GeneralizedAssignment.print_and_check_sol(data, problem, x)
end
end
93 changes: 13 additions & 80 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,88 +13,21 @@ global const CL = Coluna
global const CLD = ColunaDemos

include("unit/unit_tests.jl")
include("show_functions_tests.jl")
include("full_instances_tests.jl")

unit_tests()

@testset "play gap" begin
data = CLD.GeneralizedAssignment.data("play2.txt")

coluna = JuMP.with_optimizer(Coluna.Optimizer,# #params = params,
master_factory = with_optimizer(GLPK.Optimizer),
pricing_factory = with_optimizer(GLPK.Optimizer))

problem, x, dec = CLD.GeneralizedAssignment.model(data, coluna)

JuMP.optimize!(problem)
@test abs(JuMP.objective_value(problem) - 75.0) <= 0.00001
@test CLD.GeneralizedAssignment.print_and_check_sol(data, problem, x)
end

@testset "gap - JuMP/MOI modeling" begin
data = CLD.GeneralizedAssignment.data("smallgap3.txt")

coluna = JuMP.with_optimizer(Coluna.Optimizer,# #params = params,
master_factory = with_optimizer(GLPK.Optimizer),
pricing_factory = with_optimizer(GLPK.Optimizer))

problem, x, dec = CLD.GeneralizedAssignment.model(data, coluna)

JuMP.optimize!(problem)
@test abs(JuMP.objective_value(problem) - 438.0) <= 0.00001
@test CLD.GeneralizedAssignment.print_and_check_sol(data, problem, x)
end

@testset "gap with penalties - pure master variables" begin
data = CLD.GeneralizedAssignment.data("smallgap3.txt")

coluna = JuMP.with_optimizer(Coluna.Optimizer,# #params = params,
master_factory = with_optimizer(GLPK.Optimizer),
pricing_factory = with_optimizer(GLPK.Optimizer)
)

problem, x, y, dec = CLD.GeneralizedAssignment.model_with_penalties(data, coluna)
JuMP.optimize!(problem)
@test abs(JuMP.objective_value(problem) - 416.4) <= 0.00001
end

@testset "gap with maximisation objective function" begin
data = CLD.GeneralizedAssignment.data("smallgap3.txt")

coluna = JuMP.with_optimizer(Coluna.Optimizer,# #params = params,
master_factory = with_optimizer(GLPK.Optimizer),
pricing_factory = with_optimizer(GLPK.Optimizer)
)

problem, x, dec = CLD.GeneralizedAssignment.model_max(data, coluna)
JuMP.optimize!(problem)
@test abs(JuMP.objective_value(problem) - 580.0) <= 0.00001
@testset "Full instances " begin
full_instances_tests()
end

# @testset "gap BIG instance" begin
# data = CLD.GeneralizedAssignment.data("gapC-5-100.txt")

# coluna = JuMP.with_optimizer(Coluna.Optimizer,# #params = params,
# master_factory = with_optimizer(GLPK.Optimizer),
# pricing_factory = with_optimizer(GLPK.Optimizer)
# )

# problem, x, dec = CLD.GeneralizedAssignment.model(data, coluna)
# JuMP.optimize!(problem)
# @test abs(JuMP.objective_value(problem) - 1931.0) <= 0.00001
# @test CLD.GeneralizedAssignment.print_and_check_sol(data, problem, x)
# end

@testset "play gap" begin
global_logger(ConsoleLogger(stderr, LogLevel(-4)))
data = CLD.GeneralizedAssignment.data("play2.txt")

coluna = JuMP.with_optimizer(Coluna.Optimizer,# #params = params,
master_factory = with_optimizer(GLPK.Optimizer),
pricing_factory = with_optimizer(GLPK.Optimizer)
)

problem, x, dec = CLD.GeneralizedAssignment.model(data, coluna)
JuMP.optimize!(problem)
@test abs(JuMP.objective_value(problem) - 75.0) <= 0.00001
@test CLD.GeneralizedAssignment.print_and_check_sol(data, problem, x)
end
@testset "Base.show functions " begin
# Test show functions
backup_stdout = stdout
(rd_out, wr_out) = redirect_stdout()
show_functions_tests()
close(wr_out)
close(rd_out)
redirect_stdout(backup_stdout)
end
10 changes: 10 additions & 0 deletions test/show_functions_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function show_functions_tests()
data = CLD.GeneralizedAssignment.data("play2.txt")
coluna = JuMP.with_optimizer(Coluna.Optimizer,# #params = params,
master_factory = with_optimizer(GLPK.Optimizer),
pricing_factory = with_optimizer(GLPK.Optimizer))
problem, x, dec = CLD.GeneralizedAssignment.model(data, coluna)
JuMP.optimize!(problem)
@show fieldnames(typeof(problem.moi_backend))
@test_nowarn CL._show_optimizer(problem.moi_backend.optimizer.inner.re_formulation.master.moi_optimizer)
end
1 change: 0 additions & 1 deletion test/unit/vcids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function id_unit_tests()

@test var_id < constr_id
@test CL.getsortid(constr_id) == 100 + 1000000 * 3
@test_nowarn Base.show(var_id)

return
end