### Summation with variable lower and upper bound

Posted:

**Tue Mar 19, 2019 5:48 pm**Dear all,

Im trying to sum over my binary decision variable X(f,g,t) which equals 1 if family f cooks meal g on day t and 0 otherwise. I want at least 10 days between am family cooking twice in a month.

For example:

f1*f17;

g1*g30;

t1*t20*

Some of the families have to cook twice. To have a break between the two cooking days I used the following restriction which is working perfectly fine:
Wouldnt it be possible to formulate the equation this way also?

I tried it with every possible constellation of ord and $ but didnt manage to make it work.

Would someone please help me!

Best regards

Moritz

Im trying to sum over my binary decision variable X(f,g,t) which equals 1 if family f cooks meal g on day t and 0 otherwise. I want at least 10 days between am family cooking twice in a month.

For example:

f1*f17;

g1*g30;

t1*t20*

Some of the families have to cook twice. To have a break between the two cooking days I used the following restriction which is working perfectly fine:

Code: Select all

`whatIwant(f,t)$(ord(t)>1).. Sum(g,X(f,g,t))+Sum(g,X(f,g,t+1))+Sum(g,X(f,g,t+2))+Sum(g,X(f,g,t+3))+Sum(g,X(f,g,t+4))+Sum(g,X(f,g,t+5))+Sum(g,X(f,g,t+6))+Sum(g,X(f,g,t+7))+Sum(g,X(f,g,t+8))+Sum(g,X(f,g,t+9)) =L= 1;`

Code: Select all

`WhatItried(f).. Sum(t$( (ord(t) = ord(t)+1) and (ord(t) <= ord(t)+10) ), Sum(g,X(f,g,t))) =L= 1;`

Would someone please help me!

Best regards

Moritz