简体   繁体   English

我如何才能避免在 Optaplanner 中反复打破相同硬约束的局部最优分数?

[英]How can I escape local optima score that repeatedly breaks the same hard constraint in Optaplanner?

I am working on a timetable planning problem with Optaplanner 8.31.0.我正在使用 Optaplanner 8.31.0 解决时间表规划问题。 This is built on top of the Spring Boot School Timetabling Quickstart example.这是建立在 Spring Boot School Timetabling Quickstart 示例之上的。 There are 6 hard constraints defined and no soft constraints.定义了 6 个硬约束,没有软约束。 During benchmarking the best score I can achieve on a solved dataset is -8hard/0soft.在基准测试期间,我在已解决的数据集上可以获得的最佳分数是 -8hard/0soft。 I am trying to get to 0hard/0soft.我正在尝试达到 0hard/0soft。 Looking at the 'Constraint Match Total Best Score' graph from the benchmarker, it always reports the same constraint that is being broken in the final score.查看来自基准测试程序的“约束匹配总最佳分数”图表,它总是报告在最终分数中被打破的相同约束。 Each time, it reports that 8 Teacher Conflict constraints have been broken.每次,它都会报告 8 个 Teacher Conflict 约束已被打破。 The specific constraint mentioned is one of the included constraints with the example:提到的特定约束是示例中包含的约束之一:

` `

Constraint teacherConflict(ConstraintFactory constraintFactory) {
  // A teacher can teach at most one lesson at the same time.
  return constraintFactory
      .forEachUniquePair(Lesson.class,
          Joiners.equal(Lesson::getTimeslot),
          Joiners.equal(Lesson::getTeacher))
      .penalize(HardSoftScore.ONE_HARD)
      .asConstraint("Teacher conflict");
}

` `

I have tried FIRST_FIT, FIRST_FIT_DECREASING and ALLOCATE_ENTITY_FROM_QUEUE construction heuristics with all local search algorithms.我已经用所有本地搜索算法尝试了 FIRST_FIT、FIRST_FIT_DECREASING 和 ALLOCATE_ENTITY_FROM_QUEUE 构造启发式算法。 The best construction heuristics seem to be FIRST_FIT_DECREASING and ALLOCATE_ENTITY_FROM_QUEUE with the STEP_COUNTING_HILL_CLIMBING local search.最好的构造启发式方法似乎是 FIRST_FIT_DECREASING 和 ALLOCATE_ENTITY_FROM_QUEUE 以及 STEP_COUNTING_HILL_CLIMBING 本地搜索。 These combinations always result in the -8hard score with other combinations and algorithms giving worse scores.这些组合总是导致 -8 的硬分数,而其他组合和算法给出更差的分数。 I have tried adding another phase to the solver with various move selectors to try to break out of the local optima that it seems to be stuck in. However, I can't seem to find any combination of move selectors and local search algorithm to improve the score.我尝试使用各种移动选择器向求解器添加另一个阶段,以尝试突破它似乎陷入的局部最优状态。但是,我似乎找不到移动选择器和本地搜索算法的任何组合来改进分数。

I found some questions relating to breaking out of local optima such as this where the advice is to check for score traps;我发现了一些与打破局部最优有关的问题,比如这个建议是检查分数陷阱; introduce various moves;介绍各种动作; and implement something called iterative local search whereby you can ruin part of the solution and then recreate it randomly.并实施一种称为迭代本地搜索的方法,您可以借此破坏部分解决方案,然后随机重新创建它。

Due to the fact that the reported hard constraint above comes from the provided school timetable example I don't think my problem is with a score trap.由于上面报告的硬约束来自提供的学校时间表示例,我认为我的问题不是分数陷阱。 However I could be wrong about that.但是我可能是错的。 Is there a chance that the above constraint is falling into a score trap?上述约束是否有可能落入分数陷阱?

I have experimented with various move selectors except for mimic selection and nearby selection .除了mimic selectionnearby selection之外,我已经尝试过各种移动选择器。 Would these move types help in this situation?这些移动类型在这种情况下会有帮助吗?

Finally, could anyone suggest how to implement the iterative local search idea where you can destroy part of the solution and recreate it?最后,任何人都可以建议如何实现迭代局部搜索的想法,您可以在其中销毁部分解决方案并重新创建它吗? Perhaps this would be helpful in mixing things up enough to break the local optima?也许这有助于将事物混合到足以打破局部最优值的程度?

Any help is much appreciated.任何帮助深表感谢。

This is a lot of questions for a single StackOverflow question.对于单个 StackOverflow 问题,这是很多问题。 Next time, please break them up.下次,请把它们分开。

Wrt.写。 score trap - not including any soft constraints is the score trap.分数陷阱——不包括任何软约束就是分数陷阱。 The original example has plenty of soft constraints which allow the solver to better distinguish between different solutions with the same hard score.原始示例具有大量软约束,允许求解器更好地区分具有相同硬分的不同解决方案。 (How else is the solver supposed to do that?) (求解器还应该怎么做?)

(To be more precise: it doesn't really matter whether the scores are hard or soft. What matters is that if two solutions are different, their scores are also different. This is not always possible, but every time the constraints fail to do that, a score trap is introduced.) (更准确地说:分数是硬的还是软的并不重要。重要的是如果两个解决方案不同,它们的分数也不同。这并不总是可能的,但每次约束都做不到因此,引入了分数陷阱。)

Wrt.写。 nearby selection - I don't see how that could help here;附近的选择——我看不出这对这里有什么帮助; that is predominantly used in vehicle routing, where the concept of a "neighborhood" makes more sense.这主要用于车辆路线规划,其中“邻域”的概念更有意义。 That said, you may want to try enabling pillar swap and pillar change moves, maybe that will help.也就是说,您可能想尝试启用支柱交换和支柱更改移动,也许这会有所帮助。 Still, avoiding score traps is the better bet.不过,避免得分陷阱是更好的选择。

Wrt.写。 iterative local search - I am not sure why the documentation even mentions that.迭代本地搜索 - 我不确定为什么文档甚至提到了这一点。 Implementing that would be a major development effort in OptaPlanner core, one which we have not yet undertaken.实施这将是 OptaPlanner 核心的一项重大开发工作,我们尚未进行。 That said, I totally agree, this could help somewhat.也就是说,我完全同意,这可能会有所帮助。

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

相关问题 使用 Optaplanner 进行员工排班。 硬约束被打破但硬分数不被扣除 - Employee rostering with Optaplanner. Hard constraint is broken but hard score is not deducted Optaplanner 约束流:动态定义它是硬分数还是软分数 - Optaplanner Constraint streams: Dynamically define if its a hard or a soft score 如何通过 optaplanner 引擎获得没有任何硬分的解决方案 - How to get a solution without any hard score by optaplanner engine Optaplanner:添加新约束(困难) - Optaplanner: Adding new constraint(hard) 在 Optaplanner 中分析约束流分数计算 - Profiling constraint streams score calculation in Optaplanner Optaplanner-HardMediumSoftScoreHolder-如何强制求解器先将中等分数减至最小,然后将软分数减至最小? - Optaplanner - HardMediumSoftScoreHolder - How do I force the solver to minimize medium score first then soft score? 如何在OptaPlanner中添加约束一辆车只能在一个方向上go? - How to add constraint one car can only go in one direction in OptaPlanner? 如何将网站与 Optaplanner(html、javascript、php)集成? - How can i intergrating a website with Optaplanner (html,javascript,php)? OptaPlanner:如何在没有 .xml 配置文件的情况下构建求解器? - OptaPlanner: How can I build a solver without .xml config file? 如何将 Optaplanner 连接到 MS SQL 服务器? - How can i connect Optaplanner to MS SQL Server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM