How to make a 3-index summation?

Hi,

I've been programming in CPLEX/C++ and one of my constraints has a three-index sum equality, as fallow:

constraint03{j in Vplus, o in 0..(C-o_i[j])}:
sum{(i,j,o) in Ac} x[i,j,o] = sum{(j,l,o+o_i[j]) in Ac} x[j,l,o+o_i[j]]


'j' and 'o' are the same for both summatios, it's lika one arc arrive from 'i' to 'j', with capacity 'o', and after, another arc left 'j' to 'l' with capacity ('o' + 'o(j)'), where o(j) is the offer of 'j'.

Below, the piece of my code where I tried to write this constraint:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
for(j = 1; j <= (d.n-1); j++){	//j user
  for(o = 0; o <= (d.Q-d.oferta[j]); o++){
	IloExpr r3(env);
	for(i = 0; i <= (d.n-1); i++){	//starts from i=0
	  if(o >= d.oferta[i]){
	    if(i != j){
	      r3 += mono.x[d.n2 * (i) + d.n * (j) + (o)];
	    }
	  }
	}
	for(int l = 1; l <= d.n; l++){
	  if(j != l){
	    r3 -= mono.x[d.n2 * (j) + d.n * (l) + (o + d.oferta[j])];
	  }
	}
	mono.constraints.add(0 <= r3 <= 0);
	r3.end();
      }
  }

Can someone help me with this for? Thanks!
Topic archived. No new replies allowed.