我是OptaPlanner的新手,並且在配置解決方案時遇到了一些困難。我已經正確地排列了所有的類,但解算器運行時出現以下錯誤。OptaPlanner Xml配置和entitySubclass未配置爲計劃實體錯誤
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>
輸出顯示,該方案建立(可能的評估階段(0),但隨後被拋出的錯誤。任何幫助將不勝感激。
*編輯 首先感謝您的意見。定義部分類是如下
@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()
{
....
}
}
正如你可以看到類是完全註釋,所描述的,這就是爲什麼我認爲這個問題是與配置。
你確定你的配置符合你粘貼的錯誤嗎?該配置消息「entitySubclass(class ... DroolsScoreDirector)」是不可能的。 DroolsScoreDirector從來不是一個計劃實體。 –
我已經清理並重新構建了應用程序,以確保我沒有加載其他配置。爲了仔細檢查,我還對config進行了修改,以定位不同的calss。所有測試都顯示正在加載正確的配置。 – Jon