在 Pulp 中使用时间索引变量的最大时间跨度
我试图在 Pulp 中创建一个约束,其中我们利用心理学家需要执行的预定活动的最大时间跨度。 对于这个问题,我为 5 种不同的活动(活动 A、B、C、D 和 E)构建了 5 个不同的变量,索引 p 代表心理学家,d 代表一天:
A[(p,d)] for p in psychologists for d in days
B[(p,d)] for p in psychologists for d in days
C[(p,d)] for p in psychologists for d in days
D[(p,d)] for p in psychologists for d in days
E[(p,d)] for p in psychologists for d in days
I希望活动 A + 活动 B 的时间跨度在 2 天内完成,活动 A + 活动 B + 活动 C + 活动 D + 活动 E 的时间跨度应在 14 天内完成。
我尝试按如下方式使用优先变量:
Ad = lpSum(d*A[(m,d)] for p in psychologists for d in days)
Bd = lpSum(d*B[(m,d)] for p in psychologists for d in days)
Cd = lpSum(d*C[(m,d)] for p in psychologists for d in days)
Dd = lpSum(d*D[(m,d)] for p in psychologists for d in days)
Ed = lpSum(d*E[(m,d)] for p in psychologists for d in days)
schedule += Ad + Bd <= 2
schedule += Ad + Bd + Cd + Dd + Ed <= 14
但是,这似乎在 Pulp 中不起作用。
谁能帮我解决我的时间索引问题吗?
I am trying to create a constraint in Pulp where we make use of a maximum timespan for the scheduled activities that a psychologist needs to perform.
For this problem, I constructed 5 different variables for 5 different activities (activity A, B, C, D and E) with indexes p for psychologist and d for day:
A[(p,d)] for p in psychologists for d in days
B[(p,d)] for p in psychologists for d in days
C[(p,d)] for p in psychologists for d in days
D[(p,d)] for p in psychologists for d in days
E[(p,d)] for p in psychologists for d in days
I want the timespan for activity A + activity B to be completed within 2 days and the timespan for activity A + activity B + activity C + activity D + activity E should be completed within 14 days.
I tried to use precedence variables as follows:
Ad = lpSum(d*A[(m,d)] for p in psychologists for d in days)
Bd = lpSum(d*B[(m,d)] for p in psychologists for d in days)
Cd = lpSum(d*C[(m,d)] for p in psychologists for d in days)
Dd = lpSum(d*D[(m,d)] for p in psychologists for d in days)
Ed = lpSum(d*E[(m,d)] for p in psychologists for d in days)
schedule += Ad + Bd <= 2
schedule += Ad + Bd + Cd + Dd + Ed <= 14
However, this does not seem to work in Pulp.
Could anyone help me with my time-indexed problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论