Skip to content

Commit a39fc6e

Browse files
committed
Update
1 parent 3098696 commit a39fc6e

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

test/FileFormats/CBF/CBF.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,15 @@ const _WRITE_READ_MODELS = [
293293
c1: [x, y, z] in ExponentialCone()
294294
""",
295295
),
296+
(
297+
"VectorOfVariables as function in ExponentialCone",
298+
"""
299+
variables: x, y, z
300+
minobjective: x
301+
c0: [x, y, z] in Nonnegatives(3)
302+
c1: [x, y, z] in ExponentialCone()
303+
""",
304+
),
296305
(
297306
"VectorOfVariables in DualExponentialCone",
298307
"""
@@ -301,6 +310,15 @@ const _WRITE_READ_MODELS = [
301310
c1: [x, y, z] in DualExponentialCone()
302311
""",
303312
),
313+
(
314+
"VectorOfVariables as function in DualExponentialCone",
315+
"""
316+
variables: x, y, z
317+
minobjective: x
318+
c0: [x, y, z] in Nonnegatives(3)
319+
c1: [x, y, z] in DualExponentialCone()
320+
""",
321+
),
304322
(
305323
"VectorOfVariables in PowerCone",
306324
"""
@@ -674,6 +692,13 @@ function test_roundtrip_DualExponentialCone()
674692
return
675693
end
676694

695+
function test_supports_quadratic_objective()
696+
model = CBF.Model()
697+
F = MOI.ScalarQuadraticFunction{Float64}
698+
@test !MOI.supports(model, MOI.ObjectiveFunction{F}())
699+
return
677700
end
678701

702+
end # module
703+
679704
TestCBF.runtests()

test/FileFormats/FileFormats.jl

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ function test_compression()
117117
filename = joinpath(@__DIR__, "free_integer.mps")
118118
MOI.write_to_file(model, filename * ".garbage")
119119
for ext in ["", ".bz2", ".gz"]
120-
MOI.write_to_file(model, filename * ext)
121-
model2 = MOI.FileFormats.Model(filename = filename * ext)
122-
MOI.read_from_file(model2, filename)
120+
filename_ext = filename * ext
121+
MOI.write_to_file(model, filename_ext)
122+
model2 = MOI.FileFormats.Model(filename = filename_ext)
123+
MOI.read_from_file(model2, filename_ext)
123124
end
124125

125126
sleep(1.0) # Allow time for unlink to happen.
@@ -167,6 +168,27 @@ function test_Model()
167168
)
168169
end
169170

171+
function test_generic_names()
172+
# These methods were added to MOI, but then we changed the REW model to not
173+
# need them.
174+
model = MOI.Utilities.Model{Float64}()
175+
x = MOI.add_variables(model, 2)
176+
MOI.set.(model, MOI.VariableName(), x, "x")
177+
c = MOI.add_constraint.(model, 1.0 .* x, MOI.EqualTo(1.0))
178+
MOI.set.(model, MOI.ConstraintName(), c, "c")
179+
c2 = MOI.add_constraint(model, 1.0 * x[2], MOI.LessThan(1.0))
180+
MOI.set(model, MOI.ConstraintName(), c2, "R2")
181+
MOI.FileFormats.create_generic_names(model)
182+
@test MOI.get.(model, MOI.VariableName(), x) == ["C1", "C2"]
183+
c_name = MOI.get.(model, MOI.ConstraintName(), c)
184+
c2_name = MOI.get(model, MOI.ConstraintName(), c2)
185+
names = vcat(c_name, c2_name)
186+
# The names depend on the order that the constraints are parsed. Either is
187+
# okay.
188+
@test names == ["R1", "R2", "R3"] || names == ["R1", "R3", "R2"]
189+
return
190+
end
191+
170192
end
171193

172194
TestFileFormats.runtests()

0 commit comments

Comments
 (0)