@@ -1950,7 +1950,65 @@ function normspec1test(model::MOI.ModelLike, config::TestConfig)
1950
1950
end
1951
1951
end
1952
1952
1953
- normspectests = Dict (" normspec1" => normspec1test)
1953
+ function normspec2test (model:: MOI.ModelLike , config:: TestConfig )
1954
+ atol = config. atol
1955
+ rtol = config. rtol
1956
+ # Problem NormSpec2
1957
+ # min t
1958
+ # st t >= sigma_1([1 1; 1 -1; 0 1]) (i.e (t, 1, 1, 0, 1, -1, 1]) is in NormSpectralCone(3, 2))
1959
+ # Singular values are [sqrt(3), sqrt(2)], so optimal solution is:
1960
+ # t = sqrt(3)
1961
+
1962
+ @test MOIU. supports_default_copy_to (model, #= copy_names=# false )
1963
+ @test MOI. supports (model, MOI. ObjectiveFunction {MOI.SingleVariable} ())
1964
+ @test MOI. supports (model, MOI. ObjectiveSense ())
1965
+ @test MOI. supports_constraint (model, MOI. VectorAffineFunction{Float64}, MOI. NormSpectralCone)
1966
+
1967
+ MOI. empty! (model)
1968
+ @test MOI. is_empty (model)
1969
+
1970
+ t = MOI. add_variable (model)
1971
+ @test MOI. get (model, MOI. NumberOfVariables ()) == 1
1972
+
1973
+ data = Float64[1 , 1 , 0 , 1 , - 1 , 1 ]
1974
+ spec = MOI. add_constraint (model, MOI. VectorAffineFunction ([MOI. VectorAffineTerm (1 , MOI. ScalarAffineTerm (1.0 , t))], vcat (0.0 , data)), MOI. NormSpectralCone (3 , 2 ))
1975
+
1976
+ MOI. set (model, MOI. ObjectiveFunction {MOI.SingleVariable} (), MOI. SingleVariable (t))
1977
+ MOI. set (model, MOI. ObjectiveSense (), MOI. MIN_SENSE)
1978
+
1979
+ if config. solve
1980
+ @test MOI. get (model, MOI. TerminationStatus ()) == MOI. OPTIMIZE_NOT_CALLED
1981
+
1982
+ MOI. optimize! (model)
1983
+
1984
+ @test MOI. get (model, MOI. TerminationStatus ()) == config. optimal_status
1985
+
1986
+ @test MOI. get (model, MOI. PrimalStatus ()) == MOI. FEASIBLE_POINT
1987
+ if config. duals
1988
+ @test MOI. get (model, MOI. DualStatus ()) == MOI. FEASIBLE_POINT
1989
+ end
1990
+
1991
+ rt3 = sqrt (3 )
1992
+ @test MOI. get (model, MOI. ObjectiveValue ()) ≈ rt3 atol= atol rtol= rtol
1993
+ if config. dual_objective_value
1994
+ @test MOI. get (model, MOI. DualObjectiveValue ()) ≈ rt3 atol= atol rtol= rtol
1995
+ end
1996
+
1997
+ @test MOI. get (model, MOI. VariablePrimal (), t) ≈ rt3 atol= atol rtol= rtol
1998
+ @test MOI. get (model, MOI. ConstraintPrimal (), spec) ≈ vcat (rt3, data) atol= atol rtol= rtol
1999
+
2000
+ if config. duals
2001
+ invrt3 = inv (rt3)
2002
+ @test MOI. get (model, MOI. ConstraintDual (), spec) ≈ Float64[1 , 0 , invrt3, - invrt3, 0 , 0 , - invrt3] atol= atol rtol= rtol
2003
+ end
2004
+ end
2005
+ end
2006
+
2007
+
2008
+ normspectests = Dict (
2009
+ " normspec1" => normspec1test,
2010
+ " normspec2" => normspec2test,
2011
+ )
1954
2012
1955
2013
@moitestset normspec
1956
2014
@@ -2001,18 +2059,77 @@ function normnuc1test(model::MOI.ModelLike, config::TestConfig)
2001
2059
end
2002
2060
2003
2061
@test MOI. get (model, MOI. VariablePrimal (), t) ≈ rt3 + rt2 atol= atol rtol= rtol
2004
- @test MOI. get (model, MOI. ConstraintPrimal (), nuc) ≈ Float64[rt2 + rt3, 1 , 1 , 1 , - 1 , 0 , 1 ] atol= atol rtol= rtol
2062
+ @test MOI. get (model, MOI. ConstraintPrimal (), nuc) ≈ vcat (rt3 + rt2, data) atol= atol rtol= rtol
2005
2063
2006
2064
if config. duals
2007
2065
invrt2 = inv (rt2)
2008
2066
invrt3 = inv (rt3)
2009
2067
@test MOI. get (model, MOI. ConstraintDual (), nuc) ≈ Float64[1 , - invrt2, - invrt3, - invrt2, invrt3, 0 , - invrt3] atol= atol rtol= rtol
2068
+ end
2069
+ end
2070
+ end
2010
2071
2072
+ function normnuc2test (model:: MOI.ModelLike , config:: TestConfig )
2073
+ atol = config. atol
2074
+ rtol = config. rtol
2075
+ # Problem NormNuc2
2076
+ # min t
2077
+ # st t >= sum_i sigma_i([1 1; 1 -1; 0 1]) (i.e (t, 1, 1, 0, 1, -1, 1]) is in NormNuclearCone(3, 2))
2078
+ # Singular values are [sqrt(3), sqrt(2)], so optimal solution is:
2079
+ # t = sqrt(3) + sqrt(2)
2080
+
2081
+ @test MOIU. supports_default_copy_to (model, #= copy_names=# false )
2082
+ @test MOI. supports (model, MOI. ObjectiveFunction {MOI.SingleVariable} ())
2083
+ @test MOI. supports (model, MOI. ObjectiveSense ())
2084
+ @test MOI. supports_constraint (model, MOI. VectorAffineFunction{Float64}, MOI. NormNuclearCone)
2085
+
2086
+ MOI. empty! (model)
2087
+ @test MOI. is_empty (model)
2088
+
2089
+ t = MOI. add_variable (model)
2090
+ @test MOI. get (model, MOI. NumberOfVariables ()) == 1
2091
+
2092
+ data = Float64[1 , 1 , 0 , 1 , - 1 , 1 ]
2093
+ nuc = MOI. add_constraint (model, MOI. VectorAffineFunction ([MOI. VectorAffineTerm (1 , MOI. ScalarAffineTerm (1.0 , t))], vcat (0.0 , data)), MOI. NormNuclearCone (3 , 2 ))
2094
+
2095
+ MOI. set (model, MOI. ObjectiveFunction {MOI.SingleVariable} (), MOI. SingleVariable (t))
2096
+ MOI. set (model, MOI. ObjectiveSense (), MOI. MIN_SENSE)
2097
+
2098
+ if config. solve
2099
+ @test MOI. get (model, MOI. TerminationStatus ()) == MOI. OPTIMIZE_NOT_CALLED
2100
+
2101
+ MOI. optimize! (model)
2102
+
2103
+ @test MOI. get (model, MOI. TerminationStatus ()) == config. optimal_status
2104
+
2105
+ @test MOI. get (model, MOI. PrimalStatus ()) == MOI. FEASIBLE_POINT
2106
+ if config. duals
2107
+ @test MOI. get (model, MOI. DualStatus ()) == MOI. FEASIBLE_POINT
2108
+ end
2109
+
2110
+ rt3 = sqrt (3 )
2111
+ rt2 = sqrt (2 )
2112
+ @test MOI. get (model, MOI. ObjectiveValue ()) ≈ rt3 + rt2 atol= atol rtol= rtol
2113
+ if config. dual_objective_value
2114
+ @test MOI. get (model, MOI. DualObjectiveValue ()) ≈ rt3 + rt2 atol= atol rtol= rtol
2115
+ end
2116
+
2117
+ @test MOI. get (model, MOI. VariablePrimal (), t) ≈ rt3 + rt2 atol= atol rtol= rtol
2118
+ @test MOI. get (model, MOI. ConstraintPrimal (), nuc) ≈ vcat (rt3 + rt2, data) atol= atol rtol= rtol
2119
+
2120
+ if config. duals
2121
+ invrt2 = inv (rt2)
2122
+ invrt3 = inv (rt3)
2123
+ @test MOI. get (model, MOI. ConstraintDual (), nuc) ≈ Float64[1 , - invrt2, invrt3, - invrt3, 0 , - invrt2, - invrt3] atol= atol rtol= rtol
2011
2124
end
2012
2125
end
2013
2126
end
2014
2127
2015
- normnuctests = Dict (" normnuc1" => normnuc1test)
2128
+
2129
+ normnuctests = Dict (
2130
+ " normnuc1" => normnuc1test,
2131
+ " normnuc2" => normnuc2test,
2132
+ )
2016
2133
2017
2134
@moitestset normnuc
2018
2135
0 commit comments