The "sum" in constraint

I’m trying to add one constraint :sum of “t[i,j]x[i,j]<=10".
T is one "11
11” metrix and x[1:11,1:11] are binary variables.Seems to be error.12

Hello and welcome to the community. Please see the post

to learn how to ask a question so that it’s easy to help you.

3 Likes

Please post an MWE and clarify what your problem is. The constraint is correct. At least this code works on my machine:

using JuMP, CPLEX
S = 1:11
A = rand(11,11)
model = JuMP.direct_model( CPLEX.Optimizer() )
@variable(model, x[i in S, j in S], Bin)
@objective(model, Max, sum(A[i,j] * x[i,j] for i in S, j in S ) )
@constraint(model, con, sum(A[i,j] * x[i,j] for i in S, j in S ) <= 1)
optimize!(model)
1 Like