0

i m a total beginner in Choco Solver. I want to make a simple shift scheduler. i have set integer variables like this

IntVar day1 = model.intVar("day1", new int[] {0,1,2,3,4,5});  

where 0 , 1,...5 is a reference ID to an employee.

I have a total of 30 variables,(one for every day of the month) since this a monthly based shift schedule. I have set up constraints, that do not allow e.g. not be on shift for two days in a row.

My question is, how can i set up a constraint, such that each employer has a minimum of 5 shifts ie. each value in the domain appears at least 5 times in all 30 variables ?

Thank you!

MrRisoni
  • 43
  • 4

1 Answers1

1

There are several ways of doing this. Give a look at model.globalCardinality and model.count, these constraints enable to count the number of times a value is used by a set of variables.

http://choco-solver.org/apidocs/org/chocosolver/solver/constraints/IConstraintFactory.html

For instance, model.count(3, vars, model.intVar(5,10)).post(); means that between 5 and 10 variables in vars should be equal to 3, so employee 3 should do between 5 and 10 shifts.