Optaplanner: The selectionList contains 2 times the same selection

元气小坏坏 提交于 2019-12-24 13:59:37

问题


I am new to optplanner and playing around with using it to solve a timetabling problem however after all the setup, when I try to solve the problem, I get the following error:

java.lang.IllegalStateException: The selectionList contains 2 times the same selection (c0001{t000}-0 @ null + null) and (c0001{t000}-1 @ null + null).
    at org.optaplanner.core.impl.heuristic.selector.common.decorator.WeightFactorySelectionSorter.sort(WeightFactorySelectionSorter.java:58)
    at org.optaplanner.core.impl.heuristic.selector.entity.decorator.SortingEntitySelector.constructCache(SortingEntitySelector.java:44)
    at org.optaplanner.core.impl.heuristic.selector.common.SelectionCacheLifecycleBridge.phaseStarted(SelectionCacheLifecycleBridge.java:49)
    at org.optaplanner.core.impl.phase.event.PhaseLifecycleSupport.firePhaseStarted(PhaseLifecycleSupport.java:39)
    at org.optaplanner.core.impl.heuristic.selector.AbstractSelector.phaseStarted(AbstractSelector.java:47)
    at org.optaplanner.core.impl.phase.event.PhaseLifecycleSupport.firePhaseStarted(PhaseLifecycleSupport.java:39)
    at org.optaplanner.core.impl.heuristic.selector.AbstractSelector.phaseStarted(AbstractSelector.java:47)
    at org.optaplanner.core.impl.phase.event.PhaseLifecycleSupport.firePhaseStarted(PhaseLifecycleSupport.java:39)
    at org.optaplanner.core.impl.constructionheuristic.placer.AbstractEntityPlacer.phaseStarted(AbstractEntityPlacer.java:41)
    at org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase.phaseStarted(DefaultConstructionHeuristicPhase.java:124)
    at org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase.solve(DefaultConstructionHeuristicPhase.java:67)
    at org.optaplanner.core.impl.solver.DefaultSolver.runPhases(DefaultSolver.java:214)
    at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:176)

Has anyone come across this before and can you please help if you have.


回答1:


It looks like a problem in your dataset (or in a domain object's equals() method).

The selectionList contains 2 times the same selection (c0001{t000}-0 @ null + null) and (c0001{t000}-1 @ null + null).

It thinks that these 2 lectures are the same:

  • c0001...-0 // Lecture 0 of course 0001
  • c0001...-1 // Lecture 1 of course 0001

Obviously they are not equal, because they have a different lectureIndexInCourse.

Lecture inherits it's equals method from AbstractPersistable, which does equality based on id.

My bet is that your Lectures in your dataset either have a null id or there are duplicates.



来源:https://stackoverflow.com/questions/32614204/optaplanner-the-selectionlist-contains-2-times-the-same-selection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!