Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
laradicp committed Mar 6, 2021
1 parent 189e704 commit 4d32761
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/decomposition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,9 @@ function buildformulations!(
end

function reformulate!(prob::Problem, annotations::Annotations, env::Env)
if getcoefmatrix(prob.original_formulation).fillmode
closefillmode!(getcoefmatrix(prob.original_formulation))
end
decomposition_tree = annotations.tree
if decomposition_tree !== nothing
root = BD.getroot(decomposition_tree)
Expand Down
11 changes: 7 additions & 4 deletions src/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ function optimize!(prob::MathProg.Problem, annotations::Annotations, params::Par

env = Env(params)

if getcoefmatrix(prob.original_formulation).fillmode
closefillmode!(getcoefmatrix(prob.original_formulation))
end

# Apply decomposition
reformulate!(prob, annotations, env)

if prob.re_formulation != nothing
@show prob.re_formulation.master
@show prob.re_formulation.master.optimizer.inner
end

# Coluna ready to start
set_optim_start_time!(env)
@logmsg LogLevel(-1) "Coluna ready to start."
Expand All @@ -67,6 +68,8 @@ function optimize!(prob::MathProg.Problem, annotations::Annotations, params::Par
end

env.kpis.elapsed_optimization_time = elapsed_optim_time(env)
prob.re_formulation = nothing
prob.form_counter = Counter(0)

println(_to)
TO.reset_timer!(_to)
Expand Down
20 changes: 18 additions & 2 deletions test/issues_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,28 @@ function optimize_twice()
@objective(model, Max, x)
@test optimize!(model) == optimize!(model)

coluna = JuMP.optimizer_with_attributes(
model = BlockModel(coluna, direct_model = true)
@variable(model, x)
@constraint(model, x <= 1)
@objective(model, Max, x)
@test optimize!(model) == optimize!(model)

coluna = optimizer_with_attributes(
Coluna.Optimizer,
"params" => CL.Params(solver = ClA.SolveIpForm()),
"params" => Coluna.Params(
solver = Coluna.Algorithm.TreeSearchAlgorithm()
),
"default_optimizer" => GLPK.Optimizer
)
@axis(M, 1:20)
model = BlockModel(coluna)
@variable(model, x[m in M], Bin)
@dantzig_wolfe_decomposition(model, decomposition, M)
@test optimize!(model) == optimize!(model)

model = BlockModel(coluna, direct_model = true)
@variable(model, x[m in M], Bin)
@dantzig_wolfe_decomposition(model, decomposition, M)
@test optimize!(model) == optimize!(model)
end

Expand Down

0 comments on commit 4d32761

Please sign in to comment.