简体   繁体   English

Choco求解器班次调度

[英]Choco solver shift scheduling

ima total beginner in Choco Solver. ima在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. 其中0,1,... 5是员工的参考ID。

I have a total of 30 variables,(one for every day of the month) since this a monthly based shift schedule. 我总共有30个变量(每个月的每天一个),因为这是每月一次的轮班时间表。 I have set up constraints, that do not allow eg 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. 我的问题是,我如何设置约束,以使每个雇主至少有5个班次,即 each value in the domain appears at least 5 times in all 30 variables ? 域中的每个值在所有30个变量中至少出现5次?

Thank you! 谢谢!

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. 让我们看一下model.globalCardinality和model.count,这些约束使您能够计算一组变量使用值的次数。

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

For instance, model.count(3, vars, model.intVar(5,10)).post(); 例如,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. 表示vars中的5到10之间的变量应等于3,因此雇员3应该在5到10之间进行轮班。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM