Skip to content

Commit aed4efb

Browse files
committed
added more unit tests for the connection to MOI
1 parent 1827570 commit aed4efb

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"Cletheroe",
1515
"concretization",
1616
"Coptimizer",
17+
"cpsat",
1718
"cpuarchitecture",
1819
"cpubrand",
1920
"cpucores",
@@ -54,6 +55,7 @@
5455
"Mohseni",
5556
"MOIU",
5657
"Mourgias",
58+
"multiobjective",
5759
"Naeimeh",
5860
"nargs",
5961
"nblocks",
@@ -74,6 +76,8 @@
7476
"Rendl",
7577
"reresolve",
7678
"Rowstron",
79+
"rtol",
80+
"runtests",
7781
"sitename",
7882
"Sobol",
7983
"sprintf",

ext/JuMPExt/wrapper.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function _copy_attributes!(optimizer, model)
153153
MOI.set(optimizer, attr, ci, MOI.get(model, attr, ci))
154154
end
155155
else
156-
# throw(MOI.UnsupportedAttribute(attr))
156+
throw(MOI.UnsupportedAttribute(attr))
157157
end
158158
end
159159
end

test/test_jump.jl

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ include("utils.jl")
1717
AOCoptimizer.MOI.init()
1818

1919
const aoc_moi = AOCoptimizer.MOI
20+
const MOI = MathOptInterface
2021

2122
@testset verbose=verbose "Test simple JuMP problems" begin
2223
@testset "Test simple QUMO" begin
@@ -76,4 +77,79 @@ end
7677
end
7778
end
7879

80+
#=
81+
=#
82+
83+
const OPTIMIZER = MOI.instantiate(
84+
MOI.OptimizerWithAttributes(
85+
aoc_moi.Optimizer[],
86+
MOI.Silent() => true,
87+
MOI.TimeLimitSec() => 1.0,
88+
),
89+
)
90+
91+
const BRIDGED = MOI.instantiate(
92+
MOI.OptimizerWithAttributes(
93+
aoc_moi.Optimizer[],
94+
MOI.Silent() => true,
95+
MOI.TimeLimitSec() => 1.0,
96+
),
97+
with_bridge_type = Float64,
98+
)
99+
100+
const CONFIG = MOI.Test.Config(
101+
# Modify tolerances as necessary.
102+
atol = 1e-6,
103+
rtol = 1e-6,
104+
# Use MOI.LOCALLY_SOLVED for local solvers.
105+
optimal_status = MOI.LOCALLY_SOLVED,
106+
# Pass attributes or MOI functions to `exclude` to skip tests that
107+
# rely on this functionality.
108+
exclude = Any[MOI.VariableName, MOI.delete],
109+
)
110+
111+
function run_moi_tests()
112+
MOI.Test.runtests(
113+
BRIDGED,
114+
CONFIG,
115+
exclude = [
116+
"test_attribute_RawStatusString",
117+
"test_attribute_SolveTimeSec",
118+
119+
"test_HermitianPSDCone_",
120+
"test_NormNuclearCone_",
121+
"test_NormSpectralCone_",
122+
"test_basic_ScalarAffineFunction_",
123+
"test_basic_ScalarQuadraticFunction_",
124+
"test_basic_ScalarNonlinearFunction_",
125+
"test_basic_Vector",
126+
127+
"test_linear_",
128+
"test_nonlinear_",
129+
"test_conic_",
130+
"test_quadratic_",
131+
"test_constraint_",
132+
"test_objective_",
133+
"test_multiobjective_",
134+
"test_cpsat_",
135+
"test_infeasible_",
136+
"test_modification_",
137+
"test_solve_",
138+
139+
r"test_variable_solve.*bound",
140+
],
141+
# This argument is useful to prevent tests from failing on future
142+
# releases of MOI that add new tests. Don't let this number get too far
143+
# behind the current MOI release though. You should periodically check
144+
# for new tests to fix bugs and implement new features.
145+
exclude_tests_after = v"1.28.1",
146+
)
147+
148+
return nothing
149+
end
150+
151+
@testset "MathOptInterface Test Suite" begin
152+
run_moi_tests()
153+
end
154+
79155
end # module

0 commit comments

Comments
 (0)