I would like to sum how many different values of the element 'j' exist in the binary variable y(i,j,k,l) when y(i,j,k,l) = 1. For example, consider:
y(H1,C1,S1,S2) = 1
y(H1,C1,S2,S6) = 1
y(H1,C2,S1,S2) = 1
y(H1,C4,S9,S10) = 1
In the above example, there is C1, C2, C4 i.e. 3 different values for j. I want the binary variable to be limited so that the number of different j values is 2 or less. How would I go about implementing this? My initial attempt was:
Code: Select all
genHotLim(i,k,l) .. sum((j), y(i,j,k,l)) =l= 2;
For anyone savvy with heat exchanger networks, y is the binary variable for heat transfer occurring between hot stream 'i' in heat source block 'k', with cold stream 'j' in heat sink block 'l'. I want matches to be between a maximum of two streams.
I have attached my code for reference.
Thanks for the help.