Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Feb 17, 2025
1 parent 3098696 commit a39fc6e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
25 changes: 25 additions & 0 deletions test/FileFormats/CBF/CBF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ const _WRITE_READ_MODELS = [
c1: [x, y, z] in ExponentialCone()
""",
),
(
"VectorOfVariables as function in ExponentialCone",
"""
variables: x, y, z
minobjective: x
c0: [x, y, z] in Nonnegatives(3)
c1: [x, y, z] in ExponentialCone()
""",
),
(
"VectorOfVariables in DualExponentialCone",
"""
Expand All @@ -301,6 +310,15 @@ const _WRITE_READ_MODELS = [
c1: [x, y, z] in DualExponentialCone()
""",
),
(
"VectorOfVariables as function in DualExponentialCone",
"""
variables: x, y, z
minobjective: x
c0: [x, y, z] in Nonnegatives(3)
c1: [x, y, z] in DualExponentialCone()
""",
),
(
"VectorOfVariables in PowerCone",
"""
Expand Down Expand Up @@ -674,6 +692,13 @@ function test_roundtrip_DualExponentialCone()
return
end

function test_supports_quadratic_objective()
model = CBF.Model()
F = MOI.ScalarQuadraticFunction{Float64}
@test !MOI.supports(model, MOI.ObjectiveFunction{F}())
return
end

end # module

TestCBF.runtests()
28 changes: 25 additions & 3 deletions test/FileFormats/FileFormats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ function test_compression()
filename = joinpath(@__DIR__, "free_integer.mps")
MOI.write_to_file(model, filename * ".garbage")
for ext in ["", ".bz2", ".gz"]
MOI.write_to_file(model, filename * ext)
model2 = MOI.FileFormats.Model(filename = filename * ext)
MOI.read_from_file(model2, filename)
filename_ext = filename * ext
MOI.write_to_file(model, filename_ext)
model2 = MOI.FileFormats.Model(filename = filename_ext)
MOI.read_from_file(model2, filename_ext)
end

sleep(1.0) # Allow time for unlink to happen.
Expand Down Expand Up @@ -167,6 +168,27 @@ function test_Model()
)
end

function test_generic_names()
# These methods were added to MOI, but then we changed the REW model to not
# need them.
model = MOI.Utilities.Model{Float64}()
x = MOI.add_variables(model, 2)
MOI.set.(model, MOI.VariableName(), x, "x")
c = MOI.add_constraint.(model, 1.0 .* x, MOI.EqualTo(1.0))
MOI.set.(model, MOI.ConstraintName(), c, "c")
c2 = MOI.add_constraint(model, 1.0 * x[2], MOI.LessThan(1.0))
MOI.set(model, MOI.ConstraintName(), c2, "R2")
MOI.FileFormats.create_generic_names(model)
@test MOI.get.(model, MOI.VariableName(), x) == ["C1", "C2"]
c_name = MOI.get.(model, MOI.ConstraintName(), c)
c2_name = MOI.get(model, MOI.ConstraintName(), c2)
names = vcat(c_name, c2_name)
# The names depend on the order that the constraints are parsed. Either is
# okay.
@test names == ["R1", "R2", "R3"] || names == ["R1", "R3", "R2"]
return
end

end

TestFileFormats.runtests()

0 comments on commit a39fc6e

Please sign in to comment.