[英]How to get a solution without any hard score by optaplanner engine
We want to find a way how to avoid hard scores for the optaplanner solutions.我们希望找到一种方法来避免 optaplanner 解决方案的硬分。
In our enterprise optimization project, it's not allowed to generate a solution with hard constraint scores.在我们的企业优化项目中,不允许生成具有硬约束分数的解决方案。 But actually the generated results by Optaplanner engine always have some allocations with hard constraint scores.
但实际上 Optaplanner 引擎生成的结果总是有一些具有硬约束分数的分配。 when this situation happens, we will try to move the entity to the null allocation currently instead to clean the hard scores.
当这种情况发生时,我们将尝试将实体移动到当前的 null 分配中以清理硬分数。
The above solution seems not the right way to avoid hard scores.上述解决方案似乎不是避免硬分的正确方法。 Are there other methods to achieve that goal?
还有其他方法可以实现这一目标吗?
It is hard to know what is the issue without having any example of the algorithm configuration and examples of the problem, but hope this helps.如果没有任何算法配置示例和问题示例,很难知道问题是什么,但希望这会有所帮助。
If you get constraint violations (as that is what hard scores are) in your solution it means no feasible solution is being found.如果您在解决方案中遇到约束违规(因为这是硬分数),则意味着找不到可行的解决方案。 This can have a couple of reasons: * There is no feasible solution to begin with * The optimisation algorithm doesn't step fast enough or the termination makes it terminate too early.
这可能有几个原因: * 开始时没有可行的解决方案 * 优化算法的步骤不够快,或者终止使其过早终止。
Depending on the problem at hand it can be hard to verify whether a feasible solution exists, but one could draft a simple problem that is to be solved by Optaplanner to verify whether it can find it (it should be able to).根据手头的问题,可能很难验证是否存在可行的解决方案,但可以起草一个由 Optaplanner 解决的简单问题,以验证它是否可以找到它(它应该能够)。 If it doesn't then something is wrong with the modelling or objective function.
如果不是,则建模或物镜 function 有问题。
For the second point the best way to go forward is to keep track of the score calculation speed, it should preferably be in the thousands of steps per second ( > 1000/sec).对于第二点,go 前进的最佳方法是跟踪分数计算速度,最好是每秒数千步(> 1000/秒)。 If it isn't investigate using
Drools
or IncrementalScoreCalculator
for fasting computation.如果不使用
Drools
或IncrementalScoreCalculator
进行快速计算。 Also, use the benchmarker module to see if your algorithm is appropriately configured.此外,使用 benchmarker 模块查看您的算法是否配置正确。
Lastly, do you have a local search phase?最后,您有本地搜索阶段吗? A construction phase alone is way more likely to return an infeasible solution as opposed to one with a local search phase.
与具有本地搜索阶段的解决方案相比,单独的构建阶段更有可能返回不可行的解决方案。
In the user guide, see overconstrained planning .在用户指南中,请参阅过度约束的计划。 An approach of
nullable=true
and a medium score penalty on every null assignment should do what you want. nullable=true
的方法和对每个 null 分配的中等分数惩罚应该可以满足您的要求。 See K88's answer too.也请参阅 K88 的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.