KIE 项目中的构造启发式
Construction Heuristic in KIE Project
我使用了 KIE Workbench 6.5.0.Final 创建了如下的求解器配置:
<solver xStreamId="1">
<scanAnnotatedClasses xStreamId="2"/>
<scoreDirectorFactory xStreamId="3">
<scoreDefinitionType>HARD_SOFT</scoreDefinitionType>
<ksessionName>apsSession</ksessionName>
</scoreDirectorFactory>
<termination xStreamId="4">
<unimprovedSecondsSpentLimit>0</unimprovedSecondsSpentLimit>
<unimprovedMinutesSpentLimit>1</unimprovedMinutesSpentLimit>
<unimprovedHoursSpentLimit>0</unimprovedHoursSpentLimit>
<unimprovedDaysSpentLimit>0</unimprovedDaysSpentLimit>
</termination>
</solver>
当我在 Eclipse 中执行 deluging 项目时,出现以下错误,提示我需要在本地搜索之前通过 Construction Heuristic 初始化解决方案。
[main] INFO org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase - Construction Heuristic phase (0) ended: step total (273), time spent (5903), best score (-429hard/-5400soft).
Exception in thread "main" java.lang.IllegalStateException: Local Search phase (1) needs to start from an initialized solution, but the planning variable (Task.previousTaskOrMachinePlan) is uninitialized for the entity (com.esquel.fas.aps.Task@ac91282).
Initialize the solution by configuring a Construction Heuristic phase before this phase.
at org.optaplanner.core.impl.phase.AbstractPhase.assertWorkingSolutionInitialized(AbstractPhase.java:141)
at org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.phaseStarted(DefaultLocalSearchPhase.java:124)
at org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.solve(DefaultLocalSearchPhase.java:66)
at org.optaplanner.core.impl.solver.DefaultSolver.runPhases(DefaultSolver.java:215)
at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:176)
at com.esquel.fas.aps.App.main(App.java:127)
在求解器配置中添加以下内容后,一切都变得完美。
<constructionHeuristic>
<constructionHeuristicType>FIRST_FIT</constructionHeuristicType>
</constructionHeuristic>
但是,KIE 中的求解器配置 Workbench 在源代码级别不可编辑,在用户界面中也没有选项,想知道我们如何将其包含在 KIE 项目中?谢谢。
检查域模型中的 setter 和 getter,尤其是在 Task 上。检查调试日志。
我使用了 KIE Workbench 6.5.0.Final 创建了如下的求解器配置:
<solver xStreamId="1">
<scanAnnotatedClasses xStreamId="2"/>
<scoreDirectorFactory xStreamId="3">
<scoreDefinitionType>HARD_SOFT</scoreDefinitionType>
<ksessionName>apsSession</ksessionName>
</scoreDirectorFactory>
<termination xStreamId="4">
<unimprovedSecondsSpentLimit>0</unimprovedSecondsSpentLimit>
<unimprovedMinutesSpentLimit>1</unimprovedMinutesSpentLimit>
<unimprovedHoursSpentLimit>0</unimprovedHoursSpentLimit>
<unimprovedDaysSpentLimit>0</unimprovedDaysSpentLimit>
</termination>
</solver>
当我在 Eclipse 中执行 deluging 项目时,出现以下错误,提示我需要在本地搜索之前通过 Construction Heuristic 初始化解决方案。
[main] INFO org.optaplanner.core.impl.constructionheuristic.DefaultConstructionHeuristicPhase - Construction Heuristic phase (0) ended: step total (273), time spent (5903), best score (-429hard/-5400soft).
Exception in thread "main" java.lang.IllegalStateException: Local Search phase (1) needs to start from an initialized solution, but the planning variable (Task.previousTaskOrMachinePlan) is uninitialized for the entity (com.esquel.fas.aps.Task@ac91282).
Initialize the solution by configuring a Construction Heuristic phase before this phase.
at org.optaplanner.core.impl.phase.AbstractPhase.assertWorkingSolutionInitialized(AbstractPhase.java:141)
at org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.phaseStarted(DefaultLocalSearchPhase.java:124)
at org.optaplanner.core.impl.localsearch.DefaultLocalSearchPhase.solve(DefaultLocalSearchPhase.java:66)
at org.optaplanner.core.impl.solver.DefaultSolver.runPhases(DefaultSolver.java:215)
at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:176)
at com.esquel.fas.aps.App.main(App.java:127)
在求解器配置中添加以下内容后,一切都变得完美。
<constructionHeuristic>
<constructionHeuristicType>FIRST_FIT</constructionHeuristicType>
</constructionHeuristic>
但是,KIE 中的求解器配置 Workbench 在源代码级别不可编辑,在用户界面中也没有选项,想知道我们如何将其包含在 KIE 项目中?谢谢。
检查域模型中的 setter 和 getter,尤其是在 Task 上。检查调试日志。