Skip to content

Commit a5d9dcb

Browse files
committed
Clarify dual solution of pow1
1 parent b599a9a commit a5d9dcb

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

src/Test/contconic.jl

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,12 @@ function _pow1test(model::MOI.ModelLike, config::TestConfig, vecofvars::Bool)
17231723
# st x^0.9 * y^(0.1) >= |z| (i.e (x, y, z) are in the 3d power cone with a=0.9)
17241724
# x == 2
17251725
# y == 1
1726+
# Dual
1727+
# min -2α - β
1728+
# st (u/0.9)^0.9 (v/0.1)^0.1 >= |w|
1729+
# u + α = 0
1730+
# v + β = 0
1731+
# w = -1
17261732
a = 0.9
17271733
@test MOIU.supports_default_copy_to(model, #=copy_names=#false)
17281734
@test MOI.supports(model, MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}())
@@ -1749,8 +1755,8 @@ function _pow1test(model::MOI.ModelLike, config::TestConfig, vecofvars::Bool)
17491755
vc = MOI.add_constraint(model, MOI.VectorAffineFunction{Float64}(vov), MOI.PowerCone(a))
17501756
end
17511757

1752-
cx = MOI.add_constraint(model, MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1.0, v[1])], 0.), MOI.EqualTo(2.))
1753-
cy = MOI.add_constraint(model, MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1.0, v[2])], 0.), MOI.EqualTo(1.))
1758+
cx = MOI.add_constraint(model, MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1.0, v[1])], 0.0), MOI.EqualTo(2.0))
1759+
cy = MOI.add_constraint(model, MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1.0, v[2])], 0.0), MOI.EqualTo(1.0))
17541760

17551761
MOI.set(model, MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(), MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1.0, v[3])], 0.0))
17561762
MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE)
@@ -1767,22 +1773,25 @@ function _pow1test(model::MOI.ModelLike, config::TestConfig, vecofvars::Bool)
17671773
@test MOI.get(model, MOI.DualStatus()) == MOI.FEASIBLE_POINT
17681774
end
17691775

1770-
@test MOI.get(model, MOI.ObjectiveValue()) 2.0^0.9 atol=atol rtol=rtol
1771-
@test MOI.get(model, MOI.VariablePrimal(), v) [2., 1., 2^0.9] atol=atol rtol=rtol
1776+
@test MOI.get(model, MOI.ObjectiveValue()) 2^0.9 atol=atol rtol=rtol
1777+
@test MOI.get(model, MOI.VariablePrimal(), v) [2.0, 1.0, 2^0.9] atol=atol rtol=rtol
17721778

1773-
@test MOI.get(model, MOI.ConstraintPrimal(), vc) [2., 1., 2^0.9] atol=atol rtol=rtol
1779+
@test MOI.get(model, MOI.ConstraintPrimal(), vc) [2.0, 1.0, 2^0.9] atol=atol rtol=rtol
17741780

1775-
@test MOI.get(model, MOI.ConstraintPrimal(), cx) 2. atol=atol rtol=rtol
1776-
@test MOI.get(model, MOI.ConstraintPrimal(), cy) 1. atol=atol rtol=rtol
1781+
@test MOI.get(model, MOI.ConstraintPrimal(), cx) 2.0 atol=atol rtol=rtol
1782+
@test MOI.get(model, MOI.ConstraintPrimal(), cy) 1.0 atol=atol rtol=rtol
17771783

17781784
if config.duals
1785+
# Only real solution of u^10 - u^9 / 2^0.1 = -(0.1*0.9^9)/2
1786+
u_value = 0.839729692
1787+
v_value = 2^0.9 - 2u_value
17791788
u, v, w = MOI.get(model, MOI.ConstraintDual(), vc)
1780-
@test u 0.839729692 atol=atol rtol=rtol
1781-
@test v 0.1866065982 atol=atol rtol=rtol
1789+
@test u u_value atol=atol rtol=rtol
1790+
@test v v_value atol=atol rtol=rtol
17821791
@test w -1 atol=atol rtol=rtol
17831792

1784-
@test MOI.get(model, MOI.ConstraintDual(), cx) -0.839729692 atol=atol rtol=rtol
1785-
@test MOI.get(model, MOI.ConstraintDual(), cy) -0.1866065982 atol=atol rtol=rtol
1793+
@test MOI.get(model, MOI.ConstraintDual(), cx) -u_value atol=atol rtol=rtol
1794+
@test MOI.get(model, MOI.ConstraintDual(), cy) -v_value atol=atol rtol=rtol
17861795
end
17871796
end
17881797
end

0 commit comments

Comments
 (0)