title: How is a conditional summation possible in Cplex? like sumifs in Excel?
body: <p>I want to sum all used resources among times in my model (it's rcpsp model)
  how can I do it in CPLEX?
  at first I wrote this:</p>
  
  <pre><code>forall(k in K)
    forall(t in 1..f[nAct])
      sum(i in I:f[i]-d[i]&lt;=t-1 &amp;&amp; t&lt;=f[i]) r[i,k] &lt;= aR[k]; 
  </code></pre>
  
  <p>(note: K is a range for resources, nAct is number of activities, f[i] is an array dvar and indicates finishing time of activity i, d[i] is duration of i,r[i,k] is required resource of k for activity i and aR[k] is available resources of k.)</p>
  
  <p>The problem is that the cplex doesn't accept decision variable in sum's condition.
  I changed it to:</p>
  
  <pre><code>forall(k in K)
    forall(t in 1..f[nAct])
      sum(i in I) (f[i]-d[i]&lt;=t-1 &amp;&amp; t&lt;=f[i])*r[i,k] &lt;= aR[k]; 
  </code></pre>
  
  <p>But it didn't work. it made True constraints in Problem Browser after run(I don't know why) and it made this constraint ineffective.</p>
  
  <p>Any Idea how  to fix it?</p>