Skip to content

Commit

Permalink
Add tests from jump-dev#322
Browse files Browse the repository at this point in the history
  • Loading branch information
ericphanson committed Oct 28, 2019
1 parent ed6b23b commit 87042fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/problem_depot/problems/lp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
if test
@test p.optval 1 atol=atol rtol=rtol
@test evaluate(abs(x)) 1 atol=atol rtol=rtol
@test p.constraints[1].dual 1 atol=atol rtol=rtol
end

x = Variable(2,2)
Expand Down
17 changes: 12 additions & 5 deletions src/problem_depot/problems/socp.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@add_problem socp function socp_norm_2_atom(handle_problem!, ::Val{test}, atol, rtol, ::Type{T}) where {T, test}
@add_problem socp function socp_dual_norm_2_atom(handle_problem!, ::Val{test}, atol, rtol, ::Type{T}) where {T, test}
x = Variable(2, 1)
A = [1 2; 2 1; 3 4]
b = [2; 3; 4]
Expand Down Expand Up @@ -26,6 +26,7 @@
if test
@test p.optval 14.9049 atol=atol rtol=rtol
@test evaluate(norm2(A * x + b) + lambda * norm2(x)) 14.9049 atol=atol rtol=rtol
@test p.constraints[1].dual [4.4134, 5.1546] atol=atol rtol=rtol
end

x = Variable(2)
Expand All @@ -40,6 +41,7 @@
if test
@test p.optval 14.9049 atol=atol rtol=rtol
@test evaluate(norm2(A * x + b) + lambda * norm2(x)) 14.9049 atol=atol rtol=rtol
@test p.constraints[1].dual [4.4134, 5.1546] atol=atol rtol=rtol
end

x = Variable(2, 1)
Expand All @@ -55,10 +57,12 @@
if test
@test p.optval 15.4907 atol=atol rtol=rtol
@test evaluate(norm2(A * x + b) + lambda * norm_1(x)) 15.4907 atol=atol rtol=rtol
@test p.constraints[1].dual [4.7062, 5.4475] atol=atol rtol=rtol

end
end

@add_problem socp function socp_frobenius_norm_atom(handle_problem!, ::Val{test}, atol, rtol, ::Type{T}) where {T, test}
@add_problem socp function socp_dual_frobenius_norm_atom(handle_problem!, ::Val{test}, atol, rtol, ::Type{T}) where {T, test}
m = Variable(4, 5)
c = [m[3, 3] == 4, m >= 1]
p = minimize(norm(vec(m), 2), c; numeric_type = T)
Expand All @@ -70,6 +74,9 @@ end
if test
@test p.optval sqrt(35) atol=atol rtol=rtol
@test evaluate(norm(vec(m), 2)) sqrt(35) atol=atol rtol=rtol
@test p.constraints[1].dual 0.6761 atol=atol rtol=rtol
dual = 0.1690 .* ones(4, 5); dual[3, 3] = 0
@test p.constraints[2].dual dual atol=atol rtol=rtol
end
end

Expand Down Expand Up @@ -399,7 +406,7 @@ end
x = Variable(2)
A = [1 2; 2 4];
b = [3, 6];
p = minimize(norm(x, 1), A*x==b)
p = minimize(norm(x, 1), A*x==b; numeric_type = T)

if test
@test vexity(p) == ConvexVexity()
Expand All @@ -416,7 +423,7 @@ end
x = Variable(2)
A = [1 2; 2 4];
b = [3, 6];
p = minimize(norm(x, 2), A*x==b)
p = minimize(norm(x, 2), A*x==b; numeric_type = T)

test && @test vexity(p) == ConvexVexity()

Expand All @@ -432,7 +439,7 @@ end
x = Variable(2)
A = [1 2; 2 4];
b = [3, 6];
p = minimize(norm(x, Inf), A*x==b)
p = minimize(norm(x, Inf), A*x==b; numeric_type = T)

test && @test vexity(p) == ConvexVexity()

Expand Down

0 comments on commit 87042fb

Please sign in to comment.