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

unit test for unbounded pricing subproblem #1023

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
72 changes: 70 additions & 2 deletions test/unit/ColGen/colgen_default.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1567,17 +1567,85 @@ end
register!(unit_tests, "colgen", test_red_cost_calc_with_non_robust_cuts)


function unbounded_subproblem_form()
form = """
master
min
x1 + 7x2 + 2x3 + 3x4 + 100 local_art_of_cov_1 + 100 local_art_of_cov_2 + 100 local_art_of_cov_3 + 100 global_pos_art_var + 100 local_art_of_sp_lb_5 + 100 local_art_of_sp_ub_5 + 0 PricingSetupVar_sp_5
s.t.
4x1 + 2x2 + 2x3 + 3x4 + 1.0 local_art_of_cov_1 + 1.0 global_pos_art_var <= 30
x1 + x2 + x3 + 2x4 + 1.0 local_art_of_cov_2 - 1.0 local_art_of_cov_3 + 1.0 global_pos_art_var == 15
1.0 PricingSetupVar_sp_5 + 1.0 local_art_of_sp_lb_5 >= 0.0 {MasterConvexityConstr}
1.0 PricingSetupVar_sp_5 - 1.0 local_art_of_sp_ub_5 <= 2.0 {MasterConvexityConstr}

dw_sp
min
x1 + 7x2 + 2x3 + 3x4 + 0 PricingSetupVar_sp_5
s.t.
2x1 + 3x2 - 7x3 - 6x4 == 0
-x2 + 2x3 <= 0
x2 - 2x3 - 2x4 <= 0
-x2 + 3x3 + 2x4 <= 2

continuous
representatives
x1, x2, x3, x4

artificial
local_art_of_cov_1, local_art_of_cov_2, local_art_of_cov_3, global_pos_art_var, local_art_of_sp_lb_5, local_art_of_sp_ub_5

integer
pricing_setup
PricingSetupVar_sp_5

bounds
x1 >= 0.0
x2 >= 0.0
x3 >= 0.0
x4 >= 0.0
local_art_of_cov_1 >= 0.0
local_art_of_cov_2 >= 0.0
local_art_of_cov_3 >= 0.0
global_pos_art_var >= 0.0
local_art_of_sp_lb_5 >= 0.0
local_art_of_sp_ub_5 >= 0.0
1.0 <= PricingSetupVar_sp_5 <= 1.0
"""
env, master, sps, _, reform = reformfromstring(form)
return env, master, sps, reform
end

function test_colgen_unbounded_sp()
env, master, sps, reform = unbounded_subproblem_form()

# We need subsolvers to optimize the master and subproblems.
# We relax the master formulation.
ClMP.push_optimizer!(master, () -> ClA.MoiOptimizer(GLPK.Optimizer())) # we need warm start
ClMP.relax_integrality!(master)
for sp in sps
ClMP.push_optimizer!(sp, () -> ClA.MoiOptimizer(GLPK.Optimizer()))
end

Coluna.set_optim_start_time!(env)
ctx = ClA.ColGenContext(reform, ClA.ColumnGeneration())

input = Coluna.Algorithm.GlobalPrimalBoundHandler(reform)
output = ColGen.run!(ctx, env, input)
@show output
end
register!(unit_tests, "colgen", test_colgen_unbounded_sp)
guimarqu marked this conversation as resolved.
Show resolved Hide resolved

function jet_report_colgen_loop()
env, master, sps, reform = min_toy_gap_for_colgen_loop()

# We need subsolvers to optimize the master and subproblems.
# We relax the master formulation.
ClMP.push_optimizer!(master, () -> ClA.MoiOptimizer(GLPK.Optimizer())) # we need warm start
ClMP.relax_integrality!(master)
for sp in sps
ClMP.push_optimizer!(sp, () -> ClA.MoiOptimizer(GLPK.Optimizer()))
end

phase = ClA.ColGenPhase0()
ctx = ClA.ColGenContext(reform, ClA.ColumnGeneration())
ColGen.setup_reformulation!(reform, phase)
Expand All @@ -1592,4 +1660,4 @@ function jet_report_colgen_loop()
return
end
# Excluded at the moment because too many errors come from DynamicSparseArrays.
register!(unit_tests, "colgen_default", jet_report_colgen_loop; x = true)
register!(unit_tests, "colgen_default", jet_report_colgen_loop; x = true)