[英]Google Or-Tools Employee Scheduling .The condition does not work properly
根据您的约束:
for n in all_nurses:
for d in all_days:
model.Add(sum([shifts[(n, d, 1)], shifts[(n, (d+1)%7, 0)]]) <= 1)
更好的公式是
for n in all_nurses:
for d in all_days:
model.AddBoolOr([shifts[(n, d, 1)].Not(), shifts[(n, (d + 1) % 7, 0)].Not()])
参考: https : //github.com/google/or-tools/blob/aa0c6c42a523ee4c23633585b86fb6d3e090f8c8/ortools/sat/samples/bool_or_sample_sat.py#L23-L28
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.