Skip to content

Improve test coverage #90

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

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/algorithms/Chalmet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Research. 25(2), 292-300
* `MOI.TimeLimitSec()`: terminate if the time limit is exceeded and return the
list of current solutions.
"""
mutable struct Chalmet <: AbstractAlgorithm end
struct Chalmet <: AbstractAlgorithm end

function _solve_constrained_model(
model::Optimizer,
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/DominguezRios.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Sciences, 565(7), 210-228.
* `MOI.TimeLimitSec()`: terminate if the time limit is exceeded and return the
list of current solutions.
"""
mutable struct DominguezRios <: AbstractAlgorithm end
struct DominguezRios <: AbstractAlgorithm end

mutable struct _DominguezRiosBox
l::Vector{Float64}
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/KirlikSayin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ is solved for each rectangle.
* `MOI.TimeLimitSec()`: terminate if the time limit is exceeded and return the
list of current solutions.
"""
mutable struct KirlikSayin <: AbstractAlgorithm end
struct KirlikSayin <: AbstractAlgorithm end

struct _Rectangle
l::Vector{Float64}
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/TambyVanderpooten.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ reformulation is solved using one of the defining points as a starting solution.
* `MOI.TimeLimitSec()`: terminate if the time limit is exceeded and return the
list of current solutions.
"""
mutable struct TambyVanderpooten <: AbstractAlgorithm end
struct TambyVanderpooten <: AbstractAlgorithm end

function _update_search_region(
U_N::Dict{Vector{Float64},Vector{Vector{Vector{Float64}}}},
Expand Down
1 change: 1 addition & 0 deletions test/algorithms/EpsilonConstraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ function test_deprecated()
model = MOA.Optimizer(HiGHS.Optimizer)
MOI.set(model, MOA.Algorithm(), MOA.EpsilonConstraint())
@test MOI.supports(model, MOA.ObjectiveAbsoluteTolerance(1))
@test MOA.default(MOA.ObjectiveAbsoluteTolerance(1)) == 0.0
@test_logs (:warn,) MOI.set(model, MOA.ObjectiveAbsoluteTolerance(1), 1.0)
@test_logs (:warn,) MOI.get(model, MOA.ObjectiveAbsoluteTolerance(1))
return
Expand Down
50 changes: 50 additions & 0 deletions test/test_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,56 @@ function test_unnsupported_attributes()
return
end

function test_invalid_model()
model = MOA.Optimizer(HiGHS.Optimizer)
MOI.optimize!(model)
@test MOI.get(model, MOI.TerminationStatus()) == MOI.INVALID_MODEL
return
end

function test_raw_optimizer_attribuute()
model = MOA.Optimizer(HiGHS.Optimizer)
attr = MOI.RawOptimizerAttribute("presolve")
@test MOI.supports(model, attr)
@test MOI.get(model, attr) == "choose"
MOI.set(model, attr, "off")
@test MOI.get(model, attr) == "off"
return
end

function test_algorithm()
model = MOA.Optimizer(HiGHS.Optimizer)
@test MOI.supports(model, MOA.Algorithm())
@test MOI.get(model, MOA.Algorithm()) == nothing
MOI.set(model, MOA.Algorithm(), MOA.Chalmet())
@test MOI.get(model, MOA.Algorithm()) == MOA.Chalmet()
return
end

function test_copy_to()
src = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}())
MOI.set(src, MOA.Algorithm(), MOA.Chalmet())
x = MOI.add_variables(src, 2)
MOI.add_constraint.(src, x, MOI.GreaterThan(0.0))
f = MOI.Utilities.operate(vcat, Float64, 1.0 .* x...)
MOI.set(src, MOI.ObjectiveFunction{typeof(f)}(), f)
MOI.set(src, MOI.ObjectiveSense(), MOI.MAX_SENSE)
dest = MOA.Optimizer(HiGHS.Optimizer)
index_map = MOI.copy_to(dest, src)
MOI.set(dest, MOI.Silent(), true)
MOI.optimize!(dest)
@test MOI.get(dest, MOI.NumberOfVariables()) == 2
return
end

function test_scalarise()
x = MOI.VariableIndex.(1:2)
f = MOI.VectorOfVariables(x)
g = MOA._scalarise(f, [0.2, 0.8])
@test isapprox(g, 0.2 * x[1] + 0.8 * x[2])
return
end

end

TestModel.run_tests()
Loading