对于任务分配项目,同一类型的任务在同一时间有限制

For task assigning project, the same type task has limit in the sametime

我公司生产运动鞋。有些资源是有限的,比如用来生产鞋子的模具。所以,在同一时间内,相同任务类型任务的数量是有限制的,见图。

如何在任务分配中做这个约束? 我觉得这个约束非常难,所以就不尝试解决了。

请帮忙!

有 2 个约束条件?例如在这个模型中:

class Task {
   String name;
   Mold mold;
   TaskType taskType;
   ...
}


Constraint moldLimit(...) {
     return f.forEach(Task.class)
         .groupBy(Task::getMold, count())
         .filter((mold, taskCount) -> taskCount > mold.getMaxTaskCount())
         .penalize("mold limit", ONE_HARD,
              (mold, taskCount) -> taskCount - mold.getMaxTaskCount());
}



Constraint taskTypeLimit(...) {
     return f.forEach(Task.class)
         .groupBy(Task::getTaskType, count())
         .filter((taskType, taskCount) -> taskCount > taskType.getMaxTaskCount())
         .penalize("taskType limit", ONE_HARD,
              (taskType, taskCount) -> taskCount - taskType.getMaxTaskCount());
}