@@ -1901,9 +1901,9 @@ function normspec1test(model::MOI.ModelLike, config::TestConfig)
1901
1901
rtol = config. rtol
1902
1902
# Problem NormSpec1
1903
1903
# min t
1904
- # st t >= sigma_1([1 1 1 ; 1 1 1]) (i.e (t, ones(2, 3) ) is in NormSpectralCone(2, 3))
1905
- # Singular values of ones(2, 3) are [sqrt(6 ), 0 ], so optimal solution is:
1906
- # t = sqrt(6 )
1904
+ # st t >= sigma_1([1 1 0 ; 1 - 1 1]) (i.e (t, 1, 1, 1, -1, 0, 1] ) is in NormSpectralCone(2, 3))
1905
+ # Singular values are [sqrt(3 ), sqrt(2) ], so optimal solution is:
1906
+ # t = sqrt(3 )
1907
1907
1908
1908
@test MOIU. supports_default_copy_to (model, #= copy_names=# false )
1909
1909
@test MOI. supports (model, MOI. ObjectiveFunction {MOI.SingleVariable} ())
@@ -1916,7 +1916,8 @@ function normspec1test(model::MOI.ModelLike, config::TestConfig)
1916
1916
t = MOI. add_variable (model)
1917
1917
@test MOI. get (model, MOI. NumberOfVariables ()) == 1
1918
1918
1919
- spec = MOI. add_constraint (model, MOI. VectorAffineFunction ([MOI. VectorAffineTerm (1 , MOI. ScalarAffineTerm (1.0 , t))], vcat (0.0 , ones (6 ))), MOI. NormSpectralCone (2 , 3 ))
1919
+ data = Float64[1 , 1 , 1 , - 1 , 0 , 1 ]
1920
+ spec = MOI. add_constraint (model, MOI. VectorAffineFunction ([MOI. VectorAffineTerm (1 , MOI. ScalarAffineTerm (1.0 , t))], vcat (0.0 , data)), MOI. NormSpectralCone (2 , 3 ))
1920
1921
1921
1922
MOI. set (model, MOI. ObjectiveFunction {MOI.SingleVariable} (), MOI. SingleVariable (t))
1922
1923
MOI. set (model, MOI. ObjectiveSense (), MOI. MIN_SENSE)
@@ -1933,17 +1934,18 @@ function normspec1test(model::MOI.ModelLike, config::TestConfig)
1933
1934
@test MOI. get (model, MOI. DualStatus ()) == MOI. FEASIBLE_POINT
1934
1935
end
1935
1936
1936
- rt6 = sqrt (6 )
1937
- @test MOI. get (model, MOI. ObjectiveValue ()) ≈ rt6 atol= atol rtol= rtol
1937
+ rt3 = sqrt (3 )
1938
+ @test MOI. get (model, MOI. ObjectiveValue ()) ≈ rt3 atol= atol rtol= rtol
1938
1939
if config. dual_objective_value
1939
- @test MOI. get (model, MOI. DualObjectiveValue ()) ≈ rt6 atol= atol rtol= rtol
1940
+ @test MOI. get (model, MOI. DualObjectiveValue ()) ≈ rt3 atol= atol rtol= rtol
1940
1941
end
1941
1942
1942
- @test MOI. get (model, MOI. VariablePrimal (), t) ≈ rt6 atol= atol rtol= rtol
1943
- @test MOI. get (model, MOI. ConstraintPrimal (), spec) ≈ vcat (rt6, ones ( 6 ) ) atol= atol rtol= rtol
1943
+ @test MOI. get (model, MOI. VariablePrimal (), t) ≈ rt3 atol= atol rtol= rtol
1944
+ @test MOI. get (model, MOI. ConstraintPrimal (), spec) ≈ vcat (rt3, data ) atol= atol rtol= rtol
1944
1945
1945
1946
if config. duals
1946
- @test MOI. get (model, MOI. ConstraintDual (), spec) ≈ vcat (1 , fill (- inv (rt6), 6 )) atol= atol rtol= rtol
1947
+ invrt3 = inv (rt3)
1948
+ @test MOI. get (model, MOI. ConstraintDual (), spec) ≈ Float64[1 , 0 , - invrt3, 0 , invrt3, 0 , - invrt3] atol= atol rtol= rtol
1947
1949
end
1948
1950
end
1949
1951
end
@@ -1958,9 +1960,9 @@ function normnuc1test(model::MOI.ModelLike, config::TestConfig)
1958
1960
rtol = config. rtol
1959
1961
# Problem NormNuc1
1960
1962
# min t
1961
- # st t >= sum_i sigma_i([1 1 1 ; 1 1 1]) (i.e (t, ones(2, 3) ) is in NormNuclearCone(2, 3))
1962
- # Singular values of ones(2, 3) are [sqrt(6 ), 0 ], so optimal solution is:
1963
- # t = sqrt(6 )
1963
+ # st t >= sum_i sigma_i([1 1 0 ; 1 - 1 1]) (i.e (t, 1, 1, 1, -1, 0, 1] ) is in NormNuclearCone(2, 3))
1964
+ # Singular values are [sqrt(3 ), sqrt(2) ], so optimal solution is:
1965
+ # t = sqrt(3) + sqrt(2 )
1964
1966
1965
1967
@test MOIU. supports_default_copy_to (model, #= copy_names=# false )
1966
1968
@test MOI. supports (model, MOI. ObjectiveFunction {MOI.SingleVariable} ())
@@ -1973,7 +1975,8 @@ function normnuc1test(model::MOI.ModelLike, config::TestConfig)
1973
1975
t = MOI. add_variable (model)
1974
1976
@test MOI. get (model, MOI. NumberOfVariables ()) == 1
1975
1977
1976
- nuc = MOI. add_constraint (model, MOI. VectorAffineFunction ([MOI. VectorAffineTerm (1 , MOI. ScalarAffineTerm (1.0 , t))], vcat (0.0 , ones (6 ))), MOI. NormNuclearCone (2 , 3 ))
1978
+ data = Float64[1 , 1 , 1 , - 1 , 0 , 1 ]
1979
+ nuc = MOI. add_constraint (model, MOI. VectorAffineFunction ([MOI. VectorAffineTerm (1 , MOI. ScalarAffineTerm (1.0 , t))], vcat (0.0 , data)), MOI. NormNuclearCone (2 , 3 ))
1977
1980
1978
1981
MOI. set (model, MOI. ObjectiveFunction {MOI.SingleVariable} (), MOI. SingleVariable (t))
1979
1982
MOI. set (model, MOI. ObjectiveSense (), MOI. MIN_SENSE)
@@ -1990,17 +1993,21 @@ function normnuc1test(model::MOI.ModelLike, config::TestConfig)
1990
1993
@test MOI. get (model, MOI. DualStatus ()) == MOI. FEASIBLE_POINT
1991
1994
end
1992
1995
1993
- rt6 = sqrt (6.0 )
1994
- @test MOI. get (model, MOI. ObjectiveValue ()) ≈ rt6 atol= atol rtol= rtol
1996
+ rt3 = sqrt (3 )
1997
+ rt2 = sqrt (2 )
1998
+ @test MOI. get (model, MOI. ObjectiveValue ()) ≈ rt3 + rt2 atol= atol rtol= rtol
1995
1999
if config. dual_objective_value
1996
- @test MOI. get (model, MOI. DualObjectiveValue ()) ≈ rt6 atol= atol rtol= rtol
2000
+ @test MOI. get (model, MOI. DualObjectiveValue ()) ≈ rt3 + rt2 atol= atol rtol= rtol
1997
2001
end
1998
2002
1999
- @test MOI. get (model, MOI. VariablePrimal (), t) ≈ rt6 atol= atol rtol= rtol
2000
- @test MOI. get (model, MOI. ConstraintPrimal (), nuc) ≈ vcat (rt6, ones ( 6 )) atol= atol rtol= rtol
2003
+ @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
2001
2005
2002
2006
if config. duals
2003
- @test MOI. get (model, MOI. ConstraintDual (), nuc) ≈ vcat (1 , fill (- inv (rt6), 6 )) atol= atol rtol= rtol
2007
+ invrt2 = inv (rt2)
2008
+ invrt3 = inv (rt3)
2009
+ @test MOI. get (model, MOI. ConstraintDual (), nuc) ≈ Float64[1 , - invrt2, - invrt3, - invrt2, invrt3, 0 , - invrt3] atol= atol rtol= rtol
2010
+
2004
2011
end
2005
2012
end
2006
2013
end
0 commit comments