我是 OptaPlanner 的新手,在配置解决方案时遇到了一些困难。我已经正确注释了所有类,但是当求解器运行时出现以下错误。
A planning entity is an instance of a entitySubclass (class
org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector) that is not
configured as a planning entity.
If that class (DroolsScoreDirector) (or superclass thereof) is not a entityClass
([...Part]), check your Solution implementation's annotated methods.
If it is, check your solver configuration
这是我目前使用的xml配置。
<?xml version="1.0" encoding="UTF-8"?>
<solver>
<solutionClass>(package name).SheetNesting</solutionClass>
<planningEntityClass>(package name).Part</planningEntityClass>
<scoreDirectorFactory>
<scoreDefinitionType>HARD_SOFT</scoreDefinitionType>
<scoreDrl>/Resources/Drools/NestingRules.drl</scoreDrl>
</scoreDirectorFactory>
<termination>
<maximumSecondsSpend>500</maximumSecondsSpend>
</termination>
<constructionHeuristic>
<constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
</constructionHeuristic>
<localSearch>
<unionMoveSelector>
<changeMoveSelector>
<valueSelector>
<variableName>sheet</variableName>
</valueSelector>
</changeMoveSelector>
<moveListFactory>
<moveListFactoryClass>(package name).XPosMoveFactory</moveListFactoryClass>
</moveListFactory>
<moveListFactory>
<moveListFactoryClass>(package name).YPosMoveFactory</moveListFactoryClass>
</moveListFactory>
</unionMoveSelector>
<acceptor>
<lateAcceptanceSize>600</lateAcceptanceSize>
</acceptor>
<forager>
<acceptedCountLimit>4</acceptedCountLimit>
</forager>
</localSearch>
</solver>
输出显示解决方案建立(可能评估 Phase(0) 但随后引发错误。任何帮助将不胜感激。
*编辑首先感谢您的评论。Part类的定义如下
@PlanningEntity(difficultyComparatorClass = PartComparator.class)
public class Part
{
....
@PlanningVariable(valueRangeProviderRefs = {"sheetRange"})
public Sheet getSheet()
{
....
}
@PlanningVariable(valueRangeProviderRefs = {"xPosRange"})
public double getXCenter()
{
....
}
@PlanningVariable(valueRangeProviderRefs = {"yPosRange"})
public double getYCenter()
{
....
}
}
如您所见,该类已完全注释,如所述。这就是为什么我认为问题出在配置上。