Skip to content

Commit 2bff04f

Browse files
committed
more tests
1 parent 00711bb commit 2bff04f

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test/numerical.jl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,44 @@ function test_objective_nonconvex()
819819
return
820820
end
821821

822+
function test_objective_nonconvex_2()
823+
model = Model()
824+
@variable(model, x <= 1)
825+
@constraint(model, 3 * x <= 4)
826+
@objective(model, Min, -x^2)
827+
data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model)
828+
list = ModelAnalyzer.list_of_issue_types(data)
829+
@test length(list) == 1
830+
ret = ModelAnalyzer.list_of_issues(
831+
data,
832+
ModelAnalyzer.Numerical.NonconvexQuadraticObjective,
833+
)
834+
@test length(ret) == 1
835+
#
836+
buf = IOBuffer()
837+
ModelAnalyzer.summarize(
838+
buf,
839+
ModelAnalyzer.Numerical.NonconvexQuadraticObjective,
840+
)
841+
str = String(take!(buf))
842+
@test startswith(str, "# `NonconvexQuadraticObjective`")
843+
ModelAnalyzer.summarize(
844+
buf,
845+
ModelAnalyzer.Numerical.NonconvexQuadraticObjective,
846+
verbose = false,
847+
)
848+
str = String(take!(buf))
849+
@test str == "# NonconvexQuadraticObjective"
850+
#
851+
ModelAnalyzer.summarize(buf, ret[1], verbose = true)
852+
str = String(take!(buf))
853+
@test startswith(str, "Objective is Nonconvex quadratic")
854+
ModelAnalyzer.summarize(buf, ret[1], verbose = false)
855+
str = String(take!(buf))
856+
@test startswith(str, "Objective is Nonconvex quadratic")
857+
return
858+
end
859+
822860
function test_constraint_nonconvex()
823861
model = Model()
824862
@variable(model, x <= 1)
@@ -864,6 +902,7 @@ function test_many()
864902
@variable(model, z == 4e-9)
865903
@variable(model, w[1:1] in MOI.Nonnegatives(1))
866904
@variable(model, u[1:1])
905+
@variable(model, v[1:1])
867906
@constraint(model, x + y <= 4e8)
868907
@constraint(model, x + y + 5e7 <= 2)
869908
@constraint(model, 7e6 * x + 6e-15 * y + 2e-12 >= 0)
@@ -878,6 +917,8 @@ function test_many()
878917
@constraint(model, [1.0 * x] in MOI.Nonnegatives(1))
879918
@constraint(model, [1.0 * x * x] in MOI.Nonnegatives(1))
880919
@constraint(model, u in MOI.Nonnegatives(1))
920+
@constraint(model, v in MOI.PositiveSemidefiniteConeTriangle(1))
921+
@constraint(model, [v[] - 1.0] in MOI.PositiveSemidefiniteConeTriangle(1))
881922

882923
@objective(model, Max, 1e8 * x + 8e-11 * y)
883924

0 commit comments

Comments
 (0)