Optaplanner:selectionList包含2次相同的selection
Optaplanner: The selectionList contains 2 times the same selection
我是 optplanner 的新手,正在尝试使用它来解决时间表问题,但是在完成所有设置后,当我尝试解决问题时,出现以下错误:
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)
以前有没有人遇到过这个问题,如果遇到过请帮忙。
您的数据集(或域对象的 equals() 方法)似乎有问题。
The selectionList contains 2 times the same selection (c0001{t000}-0 @ null + null) and (c0001{t000}-1 @ null + null).
认为这2讲是一样的:
- c0001...-0 // 第 0 课当然是 0001
- c0001...-1 // 第 1 课当然是 0001
显然他们不相等,因为他们有不同的lectureIndexInCourse。
Lecture 继承了 AbstractPersistable 的 equals 方法,该方法基于 id 进行相等处理。
我敢打赌,您的数据集中的讲座 ID 为空或重复。
我是 optplanner 的新手,正在尝试使用它来解决时间表问题,但是在完成所有设置后,当我尝试解决问题时,出现以下错误:
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)
以前有没有人遇到过这个问题,如果遇到过请帮忙。
您的数据集(或域对象的 equals() 方法)似乎有问题。
The selectionList contains 2 times the same selection (c0001{t000}-0 @ null + null) and (c0001{t000}-1 @ null + null).
认为这2讲是一样的:
- c0001...-0 // 第 0 课当然是 0001
- c0001...-1 // 第 1 课当然是 0001
显然他们不相等,因为他们有不同的lectureIndexInCourse。
Lecture 继承了 AbstractPersistable 的 equals 方法,该方法基于 id 进行相等处理。
我敢打赌,您的数据集中的讲座 ID 为空或重复。