Skip to content

Commit

Permalink
Merge 4b3b820 into d5718d7
Browse files Browse the repository at this point in the history
  • Loading branch information
laradicp authored Feb 24, 2021
2 parents d5718d7 + 4b3b820 commit b0b7271
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 41 deletions.
5 changes: 2 additions & 3 deletions src/Algorithm/basic/solveipform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,9 @@ function optimize_with_moi!(optimizer::MoiOptimizer, form::Formulation, result::
sync_solver!(optimizer, form)
nbvars = MOI.get(form.optimizer.inner, MOI.NumberOfVariables())
if nbvars <= 0
@warn "No variable in the formulation. Coluna does not call the solver."
else
MOI.optimize!(getinner(optimizer))
@warn "No variable in the formulation."
end
MOI.optimize!(getinner(optimizer))
termination_status!(result, optimizer)
return
end
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithm/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ get_storages_usage(algo::AbstractAlgorithm, model::AbstractModel) = Tuple{Abstra
Returns algorithm's output.
"""
function run!(algo::AbstractAlgorithm, env::Env, data::AbstractData, input::AbstractInput)::AbstractOutput
error("run! not defined for algorithm $(typeof(algo)), data $(typeof(data)), and input $(typeof(input)).")
error("Cannot apply run! for arguments $(typeof(algo)), $(typeof(data)), $(typeof(input)).")
end

"""
Expand Down
40 changes: 40 additions & 0 deletions test/issues_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,42 @@ function decomposition_with_constant_in_objective()
@test objective_value(model) 307.5 + 2
end

# Issue #424
# - If you try to solve an empty model with Coluna using a SolveIpForm or SolveLpForm
# as top solver, the objective value will be 0.
# - If you try to solve an empty model using TreeSearchAlgorithm, then Coluna will
# throw an error because since there is no decomposition, there is no reformulation
# and TreeSearchAlgorithm must be run on a reformulation.
function solve_empty_model()
coluna = JuMP.optimizer_with_attributes(
Coluna.Optimizer,
"params" => CL.Params(solver = ClA.SolveIpForm()),
"default_optimizer" => GLPK.Optimizer
)
model = BlockModel(coluna)
optimize!(model)
@test JuMP.objective_value(model) == 0

coluna = JuMP.optimizer_with_attributes(
Coluna.Optimizer,
"params" => CL.Params(solver = ClA.SolveLpForm(update_ip_primal_solution = true)),
"default_optimizer" => GLPK.Optimizer
)
model = BlockModel(coluna)
optimize!(model)
@test JuMP.objective_value(model) == 0

coluna = optimizer_with_attributes(
Coluna.Optimizer,
"params" => Coluna.Params(
solver = Coluna.Algorithm.TreeSearchAlgorithm()
),
"default_optimizer" => GLPK.Optimizer
)
model = BlockModel(coluna)
@test_throws ErrorException optimize!(model)
end

function test_issues_fixed()
@testset "no_decomposition" begin
solve_with_no_decomposition()
Expand All @@ -85,6 +121,10 @@ function test_issues_fixed()
@testset "decomposition_with_constant_in_objective" begin
decomposition_with_constant_in_objective()
end

@testset "solve_empty_model" begin
solve_empty_model()
end
end

test_issues_fixed()
8 changes: 0 additions & 8 deletions test/unit/algorithms/algorithm.jl

This file was deleted.

23 changes: 0 additions & 23 deletions test/unit/algorithms/masteripheur.jl

This file was deleted.

6 changes: 0 additions & 6 deletions test/unit/unit_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ include("containers/solsandbounds.jl")
include("MathProg/types.jl")
include("MathProg/variables.jl")

include("algorithms/algorithm.jl")

include("counters.jl")
include("variable.jl")
include("constraint.jl")
Expand All @@ -24,10 +22,6 @@ function unit_tests()
end
end

@testset "algorithm.jl" begin
algorithm_unit_tests()
end

@testset "counters.jl" begin
counters_unit_tests()
end
Expand Down

0 comments on commit b0b7271

Please sign in to comment.