1

我是 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()
    {
        ....
    }
}

如您所见,该类已完全注释,如所述。这就是为什么我认为问题出在配置上。

4

2 回答 2

1

似乎错误告诉您您的 (包名称).Part 类未使用 @PlanningEntity 和 @PlanningVariable 注释,如文档中所述:http: //docs.jboss.org/drools/release/6.0.1.Final /optaplanner-docs/html_single/index.html#planningEntity

如果您的课程注释正确,请在您的问题中与我们分享。

于 2014-06-09T15:46:24.103 回答
1

该问题的错误消息有点误导。然而,它是准确的。这个问题是由配置的一个组件引起的,完全是我的疏忽。

自定义移动方法将分数导向器传递给 beforeVariableChanged(object, string) 方法,而不是 Part 类。

谢谢您的帮助。

于 2014-06-10T12:24:02.987 回答