@@ -10,7 +10,6 @@ import LinearAlgebra
1010import SparseArrays
1111using Test
1212
13- import LDLFactorizations
1413import MathOptInterface as MOI
1514
1615function runtests ()
@@ -345,13 +344,16 @@ function test_semidefinite_cholesky_fail()
345344 model = MOI. Bridges. Constraint. QuadtoSOC {Float64} (inner)
346345 x = MOI. add_variables (model, 2 )
347346 f = 0.5 * x[1 ] * x[1 ] + 1.0 * x[1 ] * x[2 ] + 0.5 * x[2 ] * x[2 ]
348- c = MOI. add_constraint (model, f, MOI. LessThan (1.0 ))
349- F, S = MOI. VectorAffineFunction{Float64}, MOI. RotatedSecondOrderCone
350- ci = only (MOI. get (inner, MOI. ListOfConstraintIndices {F,S} ()))
351- g = MOI. get (inner, MOI. ConstraintFunction (), ci)
352- y = MOI. get (inner, MOI. ListOfVariableIndices ())
353- sum_y = 1.0 * y[1 ] + 1.0 * y[2 ]
354- @test isapprox (g, MOI. Utilities. vectorize ([1.0 , 1.0 , sum_y, 0.0 ]))
347+ @test_throws (
348+ MOI. UnsupportedConstraint,
349+ MOI. add_constraint (model, f, MOI. LessThan (1.0 )),
350+ )
351+ # F, S = MOI.VectorAffineFunction{Float64}, MOI.RotatedSecondOrderCone
352+ # ci = only(MOI.get(inner, MOI.ListOfConstraintIndices{F,S}()))
353+ # g = MOI.get(inner, MOI.ConstraintFunction(), ci)
354+ # y = MOI.get(inner, MOI.ListOfVariableIndices())
355+ # sum_y = 1.0 * y[1] + 1.0 * y[2]
356+ # @test isapprox(g, MOI.Utilities.vectorize([1.0, 1.0, sum_y, 0.0]))
355357 return
356358end
357359
@@ -361,12 +363,8 @@ function test_compute_sparse_sqrt_edge_cases()
361363 [1.0 0.0 ; 0.0 2.0 ],
362364 # Cholesky works, with pivoting
363365 [1.0 0.0 1.0 ; 0.0 1.0 1.0 ; 1.0 1.0 3.0 ],
364- # Cholesky fails due to 0 eigen value. LDL works
365- [1.0 1.0 ; 1.0 1.0 ],
366366 # Cholesky succeeds, even though 0 eigen value
367367 [2.0 2.0 ; 2.0 2.0 ],
368- # Cholesky fails because of 0 column/row. LDL works
369- [2.0 0.0 ; 0.0 0.0 ],
370368 ]
371369 B = SparseArrays. sparse (A)
372370 f = zero (MOI. ScalarQuadraticFunction{eltype (A)})
@@ -381,6 +379,8 @@ function test_compute_sparse_sqrt_edge_cases()
381379 # Test failures
382380 for A in Any[
383381 [- 1.0 0.0 ; 0.0 1.0 ],
382+ [1.0 1.0 ; 1.0 1.0 ],
383+ [2.0 0.0 ; 0.0 0.0 ],
384384 # Found from test_quadratic_nonconvex_constraint_basic
385385 [0.0 - 1.0 ; - 1.0 0.0 ],
386386 # Different element type. We could potentially make this work in future,
@@ -400,20 +400,6 @@ function test_compute_sparse_sqrt_edge_cases()
400400 return
401401end
402402
403- function test_compute_sparse_sqrt_fallback ()
404- # Test the default fallback that is hit when LDLFactorizations isn't loaded.
405- # We could put the test somewhere else so it runs before this file is
406- # loaded, but that's pretty flakey for a long-term solution. Instead, we're
407- # going to abuse the lack of a strong type signature to hit it:
408- f = zero (MOI. ScalarAffineFunction{Float64})
409- A = SparseArrays. sparse ([- 1.0 0.0 ; 0.0 1.0 ])
410- @test_throws (
411- MOI. AddConstraintNotAllowed{typeof (f),MOI. GreaterThan{Float64}},
412- MOI. Bridges. Constraint. compute_sparse_sqrt (A, f, MOI. GreaterThan (0.0 )),
413- )
414- return
415- end
416-
417403end # module
418404
419405TestConstraintQuadToSOC. runtests ()
0 commit comments