简体   繁体   English

使用Optaplanner对列表中的项目进行排序

[英]Using Optaplanner to sort items in a list

we are currently evaluating optaplanner to be used in our cutting machine schedule optimization project. 我们目前正在评估optaplanner,以便在我们的切割机进度优化项目中使用。

How efficiant is optaplanner in sorting a list of items based on rules? Optaplanner根据规则对项目列表进行排序的效率如何?

A little bit of background story: 一点背景故事:

What the customer expects from us is that the tool should optimize the schedule of the cutting machines in such away that it minimizes the down time of them using the following factors: 客户对我们的期望是,该工具应尽可能优化切割机的调度,以便使用以下因素将切割机的停机时间减至最少:

  1. Orders with high priority should go over the machine first. 高优先级的订单应首先通过机器。 (Hard Score) (硬分)
  2. then orders near its due date. 然后在到期日之前下订单。 (Medium Score) (中分)
  3. Minimize the product change occurrence in the schedule, as with every change the machine needs to be down for X minutes for cleaning work. 尽量减少时间表中产品更换的发生,因为每次更换机器都需要停机X分钟才能进行清洁工作。 (Soft Score) (软评分)
  4. Minimize the knife position change between the patterns. 最小化图案之间的刀位置变化。 Every knife position change will take 5 minutes for the operator to set it. 每次换刀位置将需要5分钟,操作员才能进行设置。 (Soft Score) (软评分)
  5. if everything of above is the same, then apply the FIFO method, so the oldest item should go over the machine first. 如果以上所有内容均相同,则应用FIFO方法,因此最早的项应首先通过计算机。 (Soft Score) (软评分)

We implemented the model using the chainedVariable and shadowVariable, HardMediumSoftScore and the rules above in Drools. 我们在Drools中使用chainedVariable和shadowVariable,HardMediumSoftScore以及上述规则实现了该模型。 Optaplanner does its job very well on the first 4 rules but struggles with the last one. Optaplanner在前四个规则上做得很好,但在最后一个规则上却很挣扎。 However when I comment out all other rules then optaplanner does it just fine and I see the items being sorted correctly. 但是,当我注释掉所有其他规则时,optaplanner会很好,并且我看到项目已正确排序。

Here is the drool rule for the last rule: 这是最后一条规则的流口水规则:

rule "sort by ItemNumber"
salience 10
when
    $previousScore : Number() from accumulate(
        TaskGroup(previous!=null, previous.name > name, productType == previous.productType),
        sum(-1)
    )
    $nextScore : Number() from accumulate(
        TaskGroup(nextTaskGroup!=null, nextTaskGroup.name < name, productType == nextTaskGroup.productType),
        sum(-1)
    )
then
    scoreHolder.addSoftConstraintMatch(kcontext,$previousScore.intValue()+$nextScore.intValue());
end

Maybe the rule is not expressed in the right way, but we are having a hard time understanding why the rule does not do its job correctly when used in combination with the other rules. 也许该规则的表达方式不正确,但我们很难理解为什么该规则与其他规则结合使用时不能正确执行其工作。

Let me know if I need to provide more information (my first time posting here). 让我知道是否需要提供更多信息(我第一次在这里发布)。

Thanks in advance for the support. 预先感谢您的支持。

Some idea's to consider: make rule 3 and 4 a medium Score (switch to HardMediumSoftScore), because rule 5 starts with "if everything of above is the same", so it really deserves it's own score level, the lowest one. 需要考虑一些想法:将规则3和4设置为中等分数(切换到HardMediumSoftScore),因为规则5以“如果以上所有内容都相同”开头,因此它确实值得拥有自己的分数水平,即最低分数。

Take a look at the docs section about "fairness constraints". 看一下有关“公平约束”的文档部分。 Simply penalizing for each task the square of the difference between it's orderNumber and the previous task's orderNumber might already do what you want. 简单地为每个任务惩罚orderNumber和上一个任务的orderNumber之差的平方可能已经可以满足您的要求。 The description of rule 5 leaves some room for interpretation (for example is twice 1 order number too late worse than once 5 order numbers too late?). 规则5的说明留出了一些解释的空间(例如,两次1订单号为时已晚而不是一次5订单号为时已晚?)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM