title: CPLEX: how to use array in summation?
body: <p>Integer programming.
  I try to model the following constraint in Cplex:</p>
  
  <p>∑<em>i   ∑</em>(τ=s-Dur(i)+1)to s    x_(i,r,t,τ)  ≤1,          ∀r,∀t,∀s〗</p>
  
  <p>where x_(i,r,t,s) is the decision variable. 
  The variable τ=s-Dur(i)+1 is used as auxiliary variable.
  It is not possible to model this sum including an array. Thank you.</p>
  
  <pre><code> range I = 1..operations;
   range J = 1..surgeons;
   range T = 1..timeBlock;
   range S = 1..timePeriod;
   range R = 1..room;
  
  int Duration[I] =...;
  
  
  //DVars
  dvar int assignment[I][R][T][S] in 0..1;
  
  //Objective function
  
  maximize sum (i in I, r in R, t in T, s in S) (Duration[i] * assignment[i][r][t][s]);
  
  
  // constraint
  forall (r in R, t in T, s in S)
  {
  sum(i in I, s-Duration[i]+1 in s) (assignment[i][r][t][s-Dur[i]+1]) &lt;= 1;
  }
  </code></pre>