I have a set of nodes:
nodes = ["uno","dos","tres","cuatro","cinco","seis"]
and its set of all possible pairs
pairs = [(i,j) for i in nodes for j in nodes if i!=j]
Also, I have a vector of this set of pairs
d = [9, 26, 19, 13, 12, 11, 14, 26, 7, 18, 30, 19, 30, 24, 8, 21, 9,
11, 22, 16, 14, 14, 8, 9, 20, 26, 1, 22, 24, 13]
Each element of this vector it is associated with each element of the set of pairs. First pair with 9, second pair with 26, and so on.
There is the binary variable
Z = mdl.binary_var_dict(pairs, name = "Z")
associated with the set of pairs
The problem is that I am trying to write the expression
sum((d[p]*Z[p]) for p in pairs)
but I cannot do that because the vector d is not associated with the set of pairs.
How do I must write? Thanks in advance!