使用 ortools 时权重的日调度问题

问题描述

this 对我之前的一个问题的很好回答之后,我现在想知道是否有可能给每个小时赋予权重,以便强制转移到高权重的小时,即高峰时间。

分配的成本由多个权重任意给出;每小时一个。 fyr@Anatolii

@Laurent Perron:我尝试做的是: 假设每个司机的容量为 2,那么每个班次的总容量不能超过最大容量。声音怎么样?

for shift_id in range(num_shifts):
    model.Add(
        sum(driver_shifts[(driver_id,shift_id)] for driver_id in range(num_drivers)) * 2 <=
        weights[shift_id])

解决方法

你能描述一下任务的成本吗?

东西min(6 - start_hour,0) * early_penalty + max(end_hour - 21) * late_penalty

首先,写下来,给模型添加一个目标