Dear all,
I am trying to dynamically add constraints to my model as in the example below. However, this formulation results in the error stated below the formulation. I believe that the problem occurs due to the [t in t_a] in the @constraint command. Does anyone have an idea how this can be solved?
Z = @variable(m, [t in ts, cg in cgs, lt in lts2], Bin)
@constraintref limit_activation2[cgs, lts2]
for cg in cgs
for lt in lts2
t_a = [t for t in ts if t < L[t][cg][lt][“t_k”]]
limit_activation2[cg,lt] = @constraint(m, [t in t_a], Z[t,cg,lt] == 0 )
end
end
Error: MethodError: Cannot convert
an object of type JuMP.JuMPArray{JuMP.ConstraintRef,
1,Tuple{Array{Int64,1}}} to an object of type JuMP.ConstraintRef
This may have arisen from a call to the constructor JuMP.ConstraintRef(…),
since type constructors fall back to convert methods.