Skip to content

Commit

Permalink
closefillmode! outside reformulate!
Browse files Browse the repository at this point in the history
  • Loading branch information
laradicp committed Mar 5, 2021
1 parent 6658c49 commit 4f1f039
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/decomposition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ function buildformulations!(
end

function reformulate!(prob::Problem, annotations::Annotations, env::Env)
closefillmode!(getcoefmatrix(prob.original_formulation))
decomposition_tree = annotations.tree
if decomposition_tree !== nothing
root = BD.getroot(decomposition_tree)
Expand Down
4 changes: 4 additions & 0 deletions src/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ 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)

Expand Down
25 changes: 25 additions & 0 deletions test/issues_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,27 @@ function solve_empty_model()
@test_throws ErrorException optimize!(model)
end

function optimize_twice()
coluna = JuMP.optimizer_with_attributes(
Coluna.Optimizer,
"params" => CL.Params(solver = ClA.SolveIpForm()),
"default_optimizer" => GLPK.Optimizer
)
model = BlockModel(coluna)
@variable(model, x)
@constraint(model, x <= 1)
@objective(model, Max, x)
@test optimize!(model) == optimize!(model)

coluna = JuMP.optimizer_with_attributes(
Coluna.Optimizer,
"params" => CL.Params(solver = ClA.SolveIpForm()),
"default_optimizer" => GLPK.Optimizer
)
model = BlockModel(coluna, direct_model = true)
@test optimize!(model) == optimize!(model)
end

function test_issues_fixed()
@testset "no_decomposition" begin
solve_with_no_decomposition()
Expand All @@ -125,6 +146,10 @@ function test_issues_fixed()
@testset "solve_empty_model" begin
solve_empty_model()
end

@testset "optimize_twice()" begin
optimize_twice()
end
end

test_issues_fixed()

0 comments on commit 4f1f039

Please sign in to comment.