OptaPlanner Xml配置和entitySubclass未配置为计划实体错误 [英] OptaPlanner Xml configuration and entitySubclass is not configured as a planning entity error
问题描述
我是OptaPlanner的新手,在配置解决方案方面有些困难.我已经正确注释了所有类,但是运行求解器时出现以下错误.
I am new to OptaPlanner and having some diffculty in configuring the solution. I have anotated all of the classes correctly but I am getting the following error when the solver runs.
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配置.
Here is the xml configuration I am currently using.
<?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),但会引发错误.将不胜感激.
The output shows that the solution establishes (possible evaluates Phase(0) but then the error is thrown. Any help will be appreciated.
*编辑 首先,谢谢您的评论. Part类的定义如下
*EDIT Firstly thank you for your comments. The definition of the Part class is as follows
@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()
{
....
}
}
如您所见,该类已完全注释,如前所述.这就是为什么我认为问题出在配置上的原因.
As you can see the class is fully annotated, as described. This is why I believed the issue was with the configuration.
推荐答案
该问题的错误消息有些令人误解.但是,这是准确的.该问题是由配置的一个组件引起的,对我来说,这是一个完全的监督.
The error message for the problem was a little missleading. However, it was accurate. The issue was being caused by a component of the configuration and was a complete oversight on my part.
自定义移动方法是将得分控制器传递给beforeVariableChanged(object,string)方法,而不是Part类.
The custom move methods were passing the score director through to the beforeVariableChanged(object, string) method, instead of the Part class.
谢谢您的帮助.
这篇关于OptaPlanner Xml配置和entitySubclass未配置为计划实体错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!