问题描述
我们将 optaplanner 用于 VRP.我们面临的一个挑战是我们的许多限制都特定于当地.例如,在一个州,技术人员不能跨越州界,而在其他州,技术人员可以跨越州界.
We are using optaplanner for VRP. One challenge we have is many of our constraints are specific to a local area. For example, in one state Technician can't cross state line where as in other states technicians can cross state line.
在这种情况下,我们希望创建一个通用解决方案,用户可以在其中添加硬约束,通用解决方案从数据库中选择该约束以提供解决方案.
Under such scenario we want create a generic solution where user can add hard constraints and generic solution pick that constraint from data base to provide solution.
有人设计过这样的解决方案吗?
Has anyone designed such a solution?
谢谢
推荐答案
要么使用不同的 元素:
Either use different <scoreDrl>
elements:
- general.drl
- ny-specific.drl
- ca-specific.drl
- tx-specific.drl
- ...
或者,如果您需要解决同时包含 tx 和 ny 员工的单个数据集,请执行类似操作
Or if you need to solve a single dataset that contains both tx and ny employees, then do something like
class Employee {
State state;
}
rule noCross
when
Employee(state = "Texas") // doesn't apply to California
// ... crosses lines
then
...
end
这篇关于如何在 optaplanner 中动态添加/删除约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!