【发布时间】:2021-12-28 12:31:51
【问题描述】:
刚开始测试 optapy,尝试使用 optapy、groupBy 和 sum 时出错:
TypeError: 'function' 对象不可迭代"
可能是求和的论据。有什么帮助吗?
def lecturer_teaching_load(constraint_factory: ConstraintFactory):
print("Restricting by Teaching Load")
return constraint_factory.forEach(SubjectClass) \
.groupBy(lambda subject: subject.lecturer, sum(lambda subject: subject.teaching_load)) \
.filter(lambda lecturer, load: lecturer.real_cap > load) \
.penalize("Capacity conflict", HardSoftScore.ONE_HARD)
如果为同一位讲师计划的科目过多,则进行处罚。
【问题讨论】:
-
请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
-
我知道 Chris 一直在改进其中一些传递函数的 CS 案例。这是哪个版本的 optapy?
标签: group-by sum constraints optapy