@@ -2495,20 +2495,82 @@ function psdt2test(model::MOI.ModelLike, config::TestConfig)
2495
2495
end
2496
2496
end
2497
2497
2498
+ function _psd3test (model:: MOI.ModelLike , psdcone, config:: TestConfig{T} ) where T
2499
+ # min x
2500
+ # s.t. [x 1 1]
2501
+ # [1 x 1] ⪰ 0
2502
+ # [1 1 x]
2503
+
2504
+ atol = config. atol
2505
+ rtol = config. rtol
2506
+
2507
+ @test MOIU. supports_default_copy_to (model, #= copy_names=# false )
2508
+ @test MOI. supports (model, MOI. ObjectiveFunction {MOI.SingleVariable} ())
2509
+ @test MOI. supports (model, MOI. ObjectiveSense ())
2510
+ @test MOI. supports_constraint (model, MOI. VectorAffineFunction{T}, psdcone)
2511
+
2512
+ MOI. empty! (model)
2513
+ @test MOI. is_empty (model)
2514
+
2515
+ x = MOI. add_variable (model)
2516
+ fx = MOI. SingleVariable (x)
2517
+
2518
+ if psdcone == MOI. PositiveSemidefiniteConeTriangle
2519
+ func = MOIU. operate (vcat, T, fx, one (T), fx, one (T), one (T), fx)
2520
+ else
2521
+ @assert psdcone == MOI. PositiveSemidefiniteConeSquare
2522
+ func = MOIU. operate (vcat, T, fx, one (T), one (T), one (T), fx, one (T), one (T), one (T), fx)
2523
+ end
2524
+
2525
+ c = MOI. add_constraint (model, func, psdcone (3 ))
2526
+
2527
+ MOI. set (model, MOI. ObjectiveFunction {MOI.SingleVariable} (), MOI. SingleVariable (x))
2528
+ MOI. set (model, MOI. ObjectiveSense (), MOI. MIN_SENSE)
2529
+
2530
+ if config. solve
2531
+ @test MOI. get (model, MOI. TerminationStatus ()) == MOI. OPTIMIZE_NOT_CALLED
2532
+
2533
+ MOI. optimize! (model)
2534
+
2535
+ @test MOI. get (model, MOI. TerminationStatus ()) == config. optimal_status
2536
+
2537
+ @test MOI. get (model, MOI. PrimalStatus ()) == MOI. FEASIBLE_POINT
2538
+ if config. duals
2539
+ @test MOI. get (model, MOI. DualStatus ()) == MOI. FEASIBLE_POINT
2540
+ end
2541
+
2542
+ @test MOI. get (model, MOI. VariablePrimal (), x) ≈ one (T) atol= atol rtol= rtol
2543
+
2544
+ @test MOI. get (model, MOI. ConstraintPrimal (), c) ≈ ones (T, MOI. output_dimension (func)) atol= atol rtol= rtol
2545
+ if config. duals
2546
+ if psdcone == MOI. PositiveSemidefiniteConeTriangle
2547
+ @test MOI. get (model, MOI. ConstraintDual (), c) ≈ [T (2 ), - one (T), T (2 ), - one (T), - one (T), T (2 )] / T (6 ) atol= atol rtol= rtol
2548
+ else
2549
+ @assert psdcone == MOI. PositiveSemidefiniteConeSquare
2550
+ @test MOI. get (model, MOI. ConstraintDual (), c) ≈ [one (T), zero (T), zero (T), - one (T), one (T), zero (T), - one (T), - one (T), one (T)] / T (3 ) atol= atol rtol= rtol
2551
+ end
2552
+ end
2553
+ end
2554
+ end
2555
+ psdt3test (model, config) = _psd3test (model, MOI. PositiveSemidefiniteConeTriangle, config)
2556
+ psds3test (model, config) = _psd3test (model, MOI. PositiveSemidefiniteConeSquare, config)
2557
+
2498
2558
# PSDConeTriangle
2499
2559
const psdttests = Dict (" psdt0v" => psdt0vtest,
2500
2560
" psdt0f" => psdt0ftest,
2501
2561
" psdt1v" => psdt1vtest,
2502
2562
" psdt1f" => psdt1ftest,
2503
- " psdt2" => psdt2test)
2563
+ " psdt2" => psdt2test,
2564
+ " psdt3" => psdt3test)
2504
2565
2505
2566
@moitestset psdt
2506
2567
2507
2568
# PSDConeSquare
2508
2569
const psdstests = Dict (" psds0v" => psds0vtest,
2509
2570
" psds0f" => psds0ftest,
2510
2571
" psds1v" => psds1vtest,
2511
- " psds1f" => psds1ftest)
2572
+ " psds1f" => psds1ftest,
2573
+ " psds3" => psds3test)
2512
2574
2513
2575
@moitestset psds
2514
2576
0 commit comments