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

test empty model solution and improve error msg #447

Merged
merged 3 commits into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
31 changes: 31 additions & 0 deletions test/issues_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,33 @@ function decomposition_with_constant_in_objective()
@test objective_value(model) ≈ 307.5 + 2
end

# Issue #424
# Expected behaviors when trying to solve an empty model
guimarqu marked this conversation as resolved.
Show resolved Hide resolved
function solve_empty_model()
coluna = JuMP.optimizer_with_attributes(
Coluna.Optimizer,
"params" => CL.Params(solver = ClA.SolveIpForm()),
"default_optimizer" => GLPK.Optimizer
)
model = BlockModel(coluna, direct_model = true)
optimize!(model)
@test JuMP.objective_value(model) == Inf
Copy link
Contributor

Choose a reason for hiding this comment

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

The objective value must be 0.


coluna = optimizer_with_attributes(
Coluna.Optimizer,
"params" => Coluna.Params(
solver = Coluna.Algorithm.TreeSearchAlgorithm()
),
"default_optimizer" => GLPK.Optimizer
)
model = BlockModel(coluna)
try
optimize!(model)
catch e
@test repr(e) == "ErrorException(\"Cannot apply run! for arguments Coluna.Algorithm.TreeSearchAlgorithm, Coluna.Algorithm.ModelData, Coluna.Algorithm.OptimizationInput{Coluna.MathProg.Formulation{Coluna.MathProg.Original},Coluna.MathProg.MinSense}.\")"
end
Copy link
Contributor

Choose a reason for hiding this comment

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

You can replace this block by @test_throws ExceptionError optimize!(model).

end

function test_issues_fixed()
@testset "no_decomposition" begin
solve_with_no_decomposition()
Expand All @@ -85,6 +112,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()