constraintssolverconstraint-programmingchoco

Choco Solver - Variables association


I'm using choco solver 4.0.5 (latest until now) and the few examples on the web besides not contemplating my need, use older version.
I'm absolutely a begginner on choco solver, and after very hard search on the web, I came here to ask help.

I have the following variables domain:
Days of year: 1 (represents 1-jan), 35 (represents 4-feb), 58, 56, 125, 142, 168, 225, 360, 364... People Ids: 789111, 789555, 78496, 879...

I need create a constraint in order that people don't be associated on a consecutive days, but alternate them in a balanced way like:

1 = 789111
35 = 789555
58 = 789496
56 = 879
125 = 789111
142 = 789555
168 = 789496
225 = 879
360 = 789111
364 = 789496 (the 789555 is unavailable here)

How can I represent this on choco solver 4.0.5?
Thank you all!!


Solution

  • Distribute events evenly over time is not an easy thing to model. A simple "proxy" is: forbid people to work on days that are close. E.g. at least two days in between. This can be modeled as:

    worker w works at t => w cannot work at t+1 and t+2 
    

    If you would model this as x[w,t]=1 iff w works at t then this becomes:

    x[w,t]=1 => x[w,t+1]=0 and x[w,t+2]=0