I'm trying to vectorize an inequality constraint comparing two Convex
types. On one side, I have Convex.MaxAtom
s, and on the other side, I have Variable
s. I want to do something like the following:
using Convex
N = 10
t = Variable(1)
v = Variable(N)
x = Variable(1)
z = rand(100)
problem = minimize(x)
problem.constraints += [t >= 0]
ccc = Vector{Convex.MaxAtom}(N)
for i = 1:N
c = -(1. + minimum(x.*z))
cc = t + c
ccc[i] = max(cc,0.)
end
problem.constraints += [ccc <= v]
but I'm getting the following error on the final constraint:
ERROR: LoadError: MethodError: no method matching isless(::Complex{Int64}, ::Int64)
I'm not sure where the Int64
types are coming in. Is there a better way of adding this constraint besides looping through and adding individual comparisons like
for i = 1:N
problem.constraints += [ccc[i] <= v[i]]
end
I'm trying to avoid this because eventually my 10 will be much larger.
In this case (thanks to Dr. Udell), it works to vectorize as
c = -(1. + xisim + minimum(x.*z))
cc = t + c
ccc = max(cc,0.)
problem.constraints += [ccc <= v]