Optaplanner得分腐败

时间:2017-10-05 11:55:56

标签: java drools optaplanner drools-planner drools-kie-server

我正在解决与车辆路径问题类似的问题,我有一条规则可以避免多名员工同时使用同一车辆。另外,我使用多级可弯曲分数仅用于详细分数计算。 有了这条规则 我启用了FAST_ASSERT,并且我发生了以下异常:

java.lang.IllegalStateException: Impossible VariableListener corruption: the expectedWorkingScore
(-788init/[0/0/-10/-20/-3/0/-12/-788/0/0]hard/[0/0/-25/-75/0]soft) is not the workingScore 
(-788init/[0/0/-10/-60/-3/0/-12/-788/0/0]hard/[0/0/-25/-75/0]soft) after all VariableListeners were triggered without changes to the genuine variables.
But all the shadow variable values are still the same, so this is impossible.
    at org.optaplanner.core.impl.score.director.AbstractScoreDirector.assertShadowVariablesAreNotStale(AbstractScoreDirector.java:472)
    at org.optaplanner.core.impl.solver.scope.DefaultSolverScope.assertShadowVariablesAreNotStale(DefaultSolverScope.java:140)
    at org.optaplanner.core.impl.phase.scope.AbstractPhaseScope.assertShadowVariablesAreNotStale(AbstractPhaseScope.java:171)
    at org.optaplanner.core.impl.phase.AbstractPhase.predictWorkingStepScore(AbstractPhase.java:169)
    at org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase.doStep(DefaultConstructionHeuristicPhase.java:108)
    at org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase.solve(DefaultConstructionHeuristicPhase.java:95)
    at org.optaplanner.core.impl.solver.AbstractSolver.runPhases(AbstractSolver.java:87)
    at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:167)

在AbstractScoreDirector中,我查看了移动类型及它的ChainedChangeMove,它的toString看起来像:

T:1568135-2-10- {T:1656844-2-10- -> T:1656844-2-10-}

这令我感到惊讶,因为它试图将相同的链分配给实体(1656844是链中的第一个实体)。

A.需要帮助理解上述异常,以便我可以修复它。
B.我们如何确保移动创建者不会创建无用的移动,即将相同的事实分配给之前的实体,就像上面一样?

更新了FULL_ASSERT例外:

java.lang.IllegalStateException: Score corruption: the workingScore
([0/0/0/-1440/-602/0/-633/0/0/0]hard/[-120/0/-813/-2946/0]soft) is not the uncorruptedScore
([0/0/0/-1640/-602/0/-633/0/0/0]hard/[-120/0/-813/-2946/0]soft) after completedAction
 (T:1692296-2-5- {T:1690774-2-10- -> T:1690774-2-10-}):
  The corrupted scoreDirector has no ConstraintMatch(s) which are in excess.
  The corrupted scoreDirector has 20 ConstraintMatch(s) which are missing:
    com.kairos.planning.rules/Employees use same vehicle same time/[E:941, E:785]=[0/0/0/-10/0/0/0/0/0/0]hard/[0/0/0/0/0]soft
    com.kairos.planning.rules/Employees use same vehicle same time/[E:941, E:765]=[0/0/0/-10/0/0/0/0/0/0]hard/[0/0/0/0/0]soft
    com.kairos.planning.rules/Employees use same vehicle same time/[E:941, E:809]=[0/0/0/-10/0/0/0/0/0/0]hard/[0/0/0/0/0]soft
    com.kairos.planning.rules/Employees use same vehicle same time/[E:941, E:1049]=[0/0/0/-10/0/0/0/0/0/0]hard/[0/0/0/0/0]soft
    com.kairos.planning.rules/Employees use same vehicle same time/[E:941, E:881]=[0/0/0/-10/0/0/0/0/0/0]hard/[0/0/0/0/0]soft
    com.kairos.planning.rules/Employees use same vehicle same time/[E:941, E:961]=[0/0/0/-10/0/0/0/0/0/0]hard/[0/0/0/0/0]soft
    com.kairos.planning.rules/Employees use same vehicle same time/[E:785, E:941]=[0/0/0/-10/0/0/0/0/0/0]hard/[0/0/0/0/0]soft
    com.kairos.planning.rules/Employees use same vehicle same time/[E:765, E:941]=[0/0/0/-10/0/0/0/0/0/0]hard/[0/0/0/0/0]soft
    ... 12 more
  Check your score constraints.
    at org.optaplanner.core.impl.score.director.AbstractScoreDirector.assertWorkingScoreFromScratch(AbstractScoreDirector.java:491)
    at org.optaplanner.core.impl.solver.scope.DefaultSolverScope.assertWorkingScoreFromScratch(DefaultSolverScope.java:132)
    at org.optaplanner.core.impl.phase.scope.AbstractPhaseScope.assertWorkingScoreFromScratch(AbstractPhaseScope.java:167)
    at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.processMove(LocalSearchDecider.java:163)
    at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.doMove(LocalSearchDecider.java:148)
    at org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.decideNextStep(LocalSearchDecider.java:120)
    at org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.solve(DefaultLocalSearchPhase.java:70)
    at org.optaplanner.core.impl.solver.AbstractSolver.runPhases(AbstractSolver.java:87)
    at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:167)

0 个答案:

没有答案