Topic
• 2 replies
• Latest Post - ‏2014-04-10T02:04:40Z by appleme
appleme
7 Posts

# Pinned topic How to speed this model?

‏2014-04-09T02:41:44Z | alwaysin cumulfunction

Hi,all

{string} Process = ...;

tuple  JUP
{
string p;
string u;
} ;

{JUP} jup=...;

tuple ShiftC
{
string p;
int index;
int count;
int startT;
int endT;
};
{ShiftC} shiftCon=...;

dvar interval jup1[o in jup];

cumulFunction f[p in Process] = sum(o in jup:o.bo.p==p) stepAtStart(jup1[o],1)-sum(o in jup:o.bo.p==p) stepAtEnd(jup1[o],1);

forall(p in Process:p)
forall(shift in shiftCon:shift.p==p)
{

alwaysIn(f[p],shift.startT ,shift.endT, 0, shift.count);

}

I found It run very slower if I use  cumulFunction and  alwaysIn,Is there a faster method?

Or I want to add a prior condition  before "alwaysIn(f[p],shift.startT ,shift.endT, 0, shift.count)"

tuple ConC
{
string p;
int index;
string u;
};
{ConC} conCon=...;
dvar  int+ zz[conCon] in 0..1;

forall(o in jup:o.bo.p==p,con in conCon:con.p==p&&con.index==shift.index&&con.u==o.u) ((startOf(jup1[o])>=shift.startT&&startOf(jup1[o])<=shift.endT && sizeOf(jup1[o])!=0)|| (endOf(jup1[o])>=shift.startT&&endOf(jup1[o])<=shift.endT && sizeOf(jup1[o])!=0)) => (zz[con] == 1);

count(all(con in conCon:con.p==p&&con.index==shift.index) zz[con], 1)>shift.count=>alwaysIn(f[p],shift.startT ,shift.endT, 0, shift.count);

,But it does not work.

How could I do?

• PhilippeLaborie
102 Posts

#### Re: How to speed this model?

‏2014-04-09T07:58:32Z

Hello,

Could you elaborate a little more on the fact the model with cumulFunction is "slow"? What do you mean exactly? Slow to find an initial feasible solution? Slow to prove optimality? What is the typical number of interval variables involved in the cumulFunction ?

One thing you should do in your model is to change the cumul function definition and use "pulse" instead of the combination "stepAtStart-stepAtEnd", that way, the engine knows the correlation between the positive and negative changes in the cumul function:

cumulFunction f[p in Process] = sum(o in jup:o.bo.p==p) pulse(jup1[o],1);

For your second question: alwaysIn constraints cannot be used in composite constraints like (x==1)=>alwaysIn(...).

What do you want to model? Depending on what you want to model, there you may consider models using optional interval variables and/or additional interval variables that contribute with a variable height to the cumul function (if you want to model a variable resource capacity over the different shifts).

Philippe

• appleme
7 Posts

#### Re: How to speed this model?

‏2014-04-10T02:04:40Z

Hello,

Could you elaborate a little more on the fact the model with cumulFunction is "slow"? What do you mean exactly? Slow to find an initial feasible solution? Slow to prove optimality? What is the typical number of interval variables involved in the cumulFunction ?

One thing you should do in your model is to change the cumul function definition and use "pulse" instead of the combination "stepAtStart-stepAtEnd", that way, the engine knows the correlation between the positive and negative changes in the cumul function:

cumulFunction f[p in Process] = sum(o in jup:o.bo.p==p) pulse(jup1[o],1);

For your second question: alwaysIn constraints cannot be used in composite constraints like (x==1)=>alwaysIn(...).

What do you want to model? Depending on what you want to model, there you may consider models using optional interval variables and/or additional interval variables that contribute with a variable height to the cumul function (if you want to model a variable resource capacity over the different shifts).

Philippe