I would write it like this:
set ob;
set od;
set ol within {ob,ob};
param G {ol};
param B {ol};
var RR {ol,od};
var II {ol,od};
subject to active_power_balance {i in ob, d in od}:
sum{(i,j) in ol}((RR[i,j,d]*G[i,j]) - (II[i,j,d]*B[i,j])) -
sum{(j,i) in ol}((RR[j,i,d]*G[j,i]) - (-II[j,i,d]*B[j,i])) = 0;
Since you index the constraint over "i in ob", the sums are interpreted in different ways:
- sum{(i,j) in ol} is the sum over all j such that (i,j) is in ol.
- sum{(j,i) in ol} is the sum over all j such that (j,i) is in ol.
The members of the set ol (a set of pairs) must be given in the data for the model. But if you have a formula for this set, then you can instead write "set ol =" followed by the formula.