OptaPlanner - 计划实体是未配置为计划实体的entitySubclass(类java.lang.Integer)的实例。

时间:2016-04-06 14:31:44

标签: optaplanner

我一直在尝试在Optaplanner中实现类似于Nurse Rostering问题的自定义Construction Heuristic

所有内容似乎都被正确注释,并添加到SolverConfiguration,但我一直收到此错误:

Exception in thread "main" java.lang.IllegalArgumentException: A planning entity is an instance of an entitySubclass (class java.lang.Integer) that is not configured as a planning entity.
If that class (Integer) (or superclass thereof) is not a entityClass ([class org.optaplanner.examples.nurserostering.domain.SkillRequirement, class org.optaplanner.examples.nurserostering.domain.ShiftAssignment]), check your Solution implementation's annotated methods.
If it is, check your solver configuration.
at org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor.findEntityDescriptorOrFail(SolutionDescriptor.java:398)
at org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor.findVariableDescriptorOrFail(SolutionDescriptor.java:443)
at org.optaplanner.core.impl.score.director.AbstractScoreDirector.beforeVariableChanged(AbstractScoreDirector.java:226)
at org.optaplanner.examples.nurserostering.domain.solver.CustomConstructionHeuristic.changeWorkingSolution   (CustomConstructionHeuristic.java:86)
at org.optaplanner.core.impl.phase.custom.DefaultCustomPhase.doStep(DefaultCustomPhase.java:89)
at org.optaplanner.core.impl.phase.custom.DefaultCustomPhase.solve(DefaultCustomPhase.java:71)
at org.optaplanner.core.impl.solver.DefaultSolver.runPhases(DefaultSolver.java:214)
at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:176)
at org.optaplanner.examples.nurserostering.app.NurseRosterConsoleApp.main(NurseRosterConsoleApp.java:142)

我尝试使用这些引用修复它:

OptaPlanner Xml configuration and entitySubclass is not configured as a planning entity error

OptaPlanner: java.lang.IllegalArgumentException

https://groups.google.com/forum/#!topic/optaplanner-dev/wCdeSQhGdaQ

到目前为止没有任何效果。关于我如何解决这个问题的任何线索?

1 个答案:

答案 0 :(得分:1)

是的,该错误消息尚未100%用户友好,我将修复此问题。

无论如何,它说的是你在解决方案类中有这样的东西:

 @PlanningEntityCollectionProperty
 public List<Object> getMyEntities() {
     List<Object> entities = new ArrayList<>();
     entities.add(Integer.valueOf(1));
     ...
     return entities;
 }

所以你要将一个Integer添加到一个只应该存在于实体之外的集合中(所以只有SkillRequirement或ShiftAssignment的实例)。

PS:SkillRequirement是一个规划实体很奇怪,你可能想在你的护士排班变体中给这个班级一个更好的名字。