Hello all,
I am trying to express the constraint:
sets
i / 1*10 /
t / 1*24 /;
alias(i,j,k);
sets conex
/1.2
2.3
3.4
4.5
5.6
6.7
7.8
8.9
9.10/;
conex(i,j)$(conex(j,i))=1;
eq2(j,t)..P(j,t)=e=sum(i$conex(j,i),Pij(i,j,t))-sum(k$conex(j,k),Pij(j,k,t));
however, I can not add the condition “i≠k” into the eq2. Could someone help me to solve it?
Thanks.
Li
Looking at the equation, it does not make sense to be able to have a relationship between i and k.
The term containing sum over i is completely independent from the term containing sum over k. (When it is summing over k, it does not know anything about i). Therefore, it makes sense that you are not able to put a condition stating i /= k.
From the looks of it, you are trying to have sort of a sum(i, Pij) - sum(k, Pjk) type of constraint for each node j. But the problem is you are not able to distinguish between nodes i and nodes k.
One way to tackle this is by thinking how set i is different from set k in the context of your problem and then using that to define the ‘if’ condition.