I am having a hard time trying to translate a convex optimization problem from Convex.jl to JuMP.jl:
using Convex, ECOS
# generate some data
n = 100
e = [sin(50i)*sin(50j) for i=1:n, j=1:n]
# optimization variable
h = Variable(n, n)
# objective
C = sum(pos(h[i,j]  e[i,j]) + pos(e[i,j]  h[i,j]) for i=1:n, j=1:n)
prob = minimize(C)
solve!(prob, ECOSSolver())
My attempt as a firsttime user was as follows:
using JuMP, ECOS
# generate some data
n = 100
e = [sin(50i)*sin(50j) for i=1:n, j=1:n]
# define problem
m = Model(solver = ECOSSolver())
# optimization variable
@variable(m, h[1:n,1:n])
# objective
C = sum(max(0,h[i,j]e[i,j]) + max(0,e[i,j]h[i,j]) for i=1:n, j=1:n)
@objective(m, Min, C)
solve(m)
The code doesn’t compile and gives me the following error:
MethodError: no method matching isless(::JuMP.GenericAffExpr{Float64,JuMP.Variable}, ::Int64)
Closest candidates are:
isless(::Char, ::Integer) at deprecated.jl:49
isless(::AbstractFloat, ::Real) at operators.jl:42
isless(::ForwardDiff.Dual{N,T<:Real}, ::Real) at /home/juliohm/.julia/v0.5/ForwardDiff/src/dual.jl:160

Can you please explain what is the issue? Are we allowed to call Julia functions like
max
directly in JuMP.jl? 
I am also wondering why the Convex.jl version takes a while (more than 5 minutes) to return even though the solver takes less than a second to solve the problem. Could someone please elaborate on what is happening with the Convex.jl approach?