From a39fc6e90b53c4353bbd275c61a8858099b38a2c Mon Sep 17 00:00:00 2001 From: odow Date: Mon, 17 Feb 2025 16:01:16 +1300 Subject: [PATCH] Update --- test/FileFormats/CBF/CBF.jl | 25 +++++++++++++++++++++++++ test/FileFormats/FileFormats.jl | 28 +++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/test/FileFormats/CBF/CBF.jl b/test/FileFormats/CBF/CBF.jl index 10520b27b7..ad40971891 100644 --- a/test/FileFormats/CBF/CBF.jl +++ b/test/FileFormats/CBF/CBF.jl @@ -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", """ @@ -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", """ @@ -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() diff --git a/test/FileFormats/FileFormats.jl b/test/FileFormats/FileFormats.jl index 7ac5a68b71..f1a5fe085a 100644 --- a/test/FileFormats/FileFormats.jl +++ b/test/FileFormats/FileFormats.jl @@ -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. @@ -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()