Skip to content

Commit

Permalink
hack to fix #117
Browse files Browse the repository at this point in the history
  • Loading branch information
mlubin committed Oct 23, 2015
1 parent f234aa3 commit 0e5a18f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/atoms/affine/stack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,17 @@ hcat(args::Value...) = Base.cat(2, args...)

# TODO: implement vertical concatenation in a more efficient way
vcat(args::AbstractExpr...) = HcatAtom([arg' for arg in args]...)'
vcat(args::AbstractExpr...) = HcatAtom([arg' for arg in args]...)'
vcat(args::AbstractExprOrValue...) = HcatAtom([convert(AbstractExpr, arg)' for arg in args]...)'
vcat(args::Value...) = Base.cat(1, args...)
vcat(args::Value...) = Base.cat(1, args...) # Note: this makes general vcat slower for anyone using Convex...
if VERSION >= v"0.4.0"
Base.vect{T<:AbstractExpr}(args::T...) = HcatAtom([arg' for arg in args]...)'
Base.vect(args::AbstractExpr...) = HcatAtom([arg' for arg in args]...)'
Base.vect(args::AbstractExprOrValue...) = HcatAtom([convert(AbstractExpr,arg)' for arg in args]...)'
if Base._oldstyle_array_vcat_
# This is ugly, because the method redefines simple cases like [1,2,3]
Base.vect(args::Value...) = Base.vcat(args...)
else
error("FIXME")
end
end
7 changes: 7 additions & 0 deletions test/test_socp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ facts("SOCP Atoms") do
@fact p.optval => roughly(14.9049, TOL)
@fact evaluate(norm2(A * x + b) + lambda * norm2(x)) => roughly(14.9049, TOL)

x = Variable(2)
p = minimize(norm2([x[1] + 2x[2] + 2, 2x[1] + x[2] + 3, 3x[1]+4x[2] + 4]) + lambda * norm2(x), x >= 1)
@fact vexity(p) => ConvexVexity()
solve!(p)
@fact p.optval => roughly(14.9049, TOL)
@fact evaluate(norm2(A * x + b) + lambda * norm2(x)) => roughly(14.9049, TOL)

x = Variable(2, 1)
A = [1 2; 2 1; 3 4]
b = [2; 3; 4]
Expand Down

0 comments on commit 0e5a18f

Please sign in to comment.