Hi,
We have two sets A = [1,2,...,N]
and B = [1,2,...,M]
. There are two other sets SA, SB
associated with A
and B
which are N-elements and M-elemets vector of vector.
A = [1:N]
B = [1:M]
SA = [ [some stuff for 1] , [some stuff for 2] ,..., [[some stuff for N] ]
SB = [ [some stuff for 1] , [some stuff for 2] ,..., [[some stuff for M] ]
I’m interested in the intersection of things between SA
and SB
to later use them for a constraint.
Therefore I did the following:
AB = [(a,b) for a in A for b in B]
SAB = [ intersect( SA[a], SB[b]) for (a,b) in AB]
This outputs N*M elements Vector of Vector. Until this point things are fine. Now I’d like to add a constrains to model that says:
sum( a in A , y[i, a, b]) <= U*x[i,j,b] for all b in B and i in SAB and j in SAB # where U is a constant
Therefore I translate it like below:
@constraint(model, [(a,b) in AB, i in SAB[a,b], j in SAB[a,b]], sum( y[i,a,b] for a in A) <= U * x[i,j,b])
But it return error like KeyError: key (this, this, this) not found
. Next time I tried this
@constraint(model, [(b in B, i in SAB[a,b], j in SAB[a,b]], sum( y[i,a,b] for a in A) <= U * x[i,j,b])
Altough I knew it’s incorrect, but the only issue is that I cannot say i in SAB[a,b]
when I only use [(b in B, i in SAB[a,b], j in SAB[a,b]]
Right??
Basically, how we could do this? Sum over b
while using elements of sahred vector like SAB
?