How is a conditional summation possible in Cplex? like sumifs in Excel?

后端 未结 2 500
再見小時候
再見小時候 2021-01-26 12:55

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:

forall(k in K)
  forall(t in 1..f[n         


        
2条回答
  •  星月不相逢
    2021-01-26 13:44

    You can use dexpr for manipulating decision variables. Here is an example from the same resource IBM Knowledge Center.

    Without dexpr

    dvar int x in 0..20;
    dvar int y in 0..20;
    dvar int d;
    dvar int s;
    maximize (d);
    subject to {
      d==x-y;
      s==x+y;
      s<=15;
      s<=x-2*y;
      d>=2;
      d<=y+8;
      1<=d;
    }
    

    With dexpr

    dvar int x in 0..20;
    dvar int y in 0..20;
    dexpr int d=x-y;
    dexpr int s=x+y;
    maximize (d);
    subject to {
      s<=15;
      s<=x-2*y;
      d>=2;
      d<=y+8;
      1<=d;
    }
    

提交回复
热议问题