Reputation: 3
I use the OptaPlanner 8.19.0. The problem has two entityClass.
But it comes out the following exception:
Failed to instantiate [org.optaplanner.core.api.solver.SolverManager]: Factory method 'solverManager' threw exception; nested exception is java.lang.IllegalArgumentException: The config (QueuedValuePlacerConfig(ValueSelectorConfig(taskCombos), ChangeMoveSelectorConfig(null, ValueSelectorConfig(null)))) has no entityClass configured and because there are multiple in the entityClassSet ([class com.aiseeding.aps.hf.domain.MachineStageFirst, class com.aiseeding.aps.hf.domain.MachineStageSecond]), it cannot be deduced automatically.
PlanningEntity1 and PlanningEntity2 are identical, but the value range is different. I tried to use valueRangeProvider on @PlanngingEntity, but optaplanner said it is not supported with a list variable. So I use two entity class and each entity class has one valueProviderRange
Solution Class:
@PlanningSolution
@XStreamAlias("TaTaskAssigningSolution")
public class APSSolution extends AbstractPersistable {
@ProblemFactCollectionProperty
private List<Tank> taskTypeList;
@ValueRangeProvider(id = "taskRangeStageFirst")
@ProblemFactCollectionProperty
private List<TaskCombo> taskComboListStageFirst;
@ValueRangeProvider(id = "taskRangeStageSecond")
@ProblemFactCollectionProperty
private List<TaskCombo> taskComboListStageSecond;
@ProblemFactCollectionProperty
private List<Tank> tankList;
@PlanningEntityCollectionProperty
private List<Machine> machineList;
@PlanningEntityCollectionProperty
private List<Machine> machineListSecond;
@XStreamConverter(BendableScoreXStreamConverter.class)
@PlanningScore(bendableHardLevelsSize = 1, bendableSoftLevelsSize = 4)
private BendableLongScore score;
/** Relates to {@link Task#()}. */
private int frozenCutoff; // In minutes
private Param param;
private List<Stage> stageList;
private Map<String,Task> taskMap;
private Map<String,Machine> machineMap;
public APSSolution(long id){}
}
PlanningEntity1 and PlanningEntity2:
@PlanningEntity
@XStreamAlias("TaEmployee")
public class MachineStageFirst extends Machine {
@PlanningListVariable(valueRangeProviderRefs = "taskRangeStageFirst")
private List<TaskCombo> taskCombos;
public MachineStageFirst()
{ }
public MachineStageFirst(long id, String fullName) {
super.setId(id);
super.setFullName(fullName);
setTaskCombos(new ArrayList<>());
}
public List<TaskCombo> getTaskCombos() {
return taskCombos;
}
public void setTaskCombos(List<TaskCombo> taskCombos) {
this.taskCombos = taskCombos;
}
}
The conifg XML:
<?xml version="1.0" encoding="UTF-8"?>
<solver>
<!--<environmentMode>FULL_ASSERT</environmentMode>--><!-- To slowly prove there are no bugs in this code -->
<moveThreadCount>1</moveThreadCount> To solve faster by saturating multiple CPU cores
<solutionClass>com.aps.hf.domain.APSSolution</solutionClass>
<entityClass>com.aps.hf.domain.MachineStageFirst</entityClass>
<entityClass>com.aps.hf.domain.MachineStageSecond</entityClass>
<scoreDirectorFactory>
<easyScoreCalculatorClass>com.aiseeding.aps.hf.score.APSConstraintScoreCalculator</easyScoreCalculatorClass>
</scoreDirectorFactory>
<termination>
<secondsSpentLimit>10</secondsSpentLimit>
</termination>
<constructionHeuristic>
<queuedValuePlacer>
<entitySelector>
<entityClass>com.aiseeding.aps.hf.domain.MachineStageFirst</entityClass>
</entitySelector>
<valueSelector id="placerValueSelector">
<cacheType>PHASE</cacheType>
<selectionOrder>SORTED</selectionOrder>
<sorterManner>INCREASING_STRENGTH</sorterManner>
</valueSelector>
<changeMoveSelector>
<entitySelector>
<cacheType>PHASE</cacheType>
<selectionOrder>SORTED</selectionOrder>
<sorterManner>DECREASING_DIFFICULTY</sorterManner>
</entitySelector>
<valueSelector mimicSelectorRef="placerValueSelector"/>
</changeMoveSelector>
</queuedValuePlacer>
</constructionHeuristic>
<constructionHeuristic>
<queuedValuePlacer>
<entitySelector>
<entityClass>com.aiseeding.aps.hf.domain.MachineStageSecond</entityClass>
</entitySelector>
<valueSelector id="placerValueSelector">
<cacheType>PHASE</cacheType>
<selectionOrder>SORTED</selectionOrder>
<sorterManner>INCREASING_STRENGTH</sorterManner>
</valueSelector>
<changeMoveSelector>
<entitySelector>
<cacheType>PHASE</cacheType>
<selectionOrder>SORTED</selectionOrder>
<sorterManner>DECREASING_DIFFICULTY</sorterManner>
</entitySelector>
<valueSelector mimicSelectorRef="placerValueSelector"/>
</changeMoveSelector>
</queuedValuePlacer>
</constructionHeuristic>
<localSearch>
<changeMoveSelector>
<entitySelector>
... <!-- Normal selector properties -->
<entityClass>com.aps.hf.domain.MachineStageFirst</entityClass>
</entitySelector>
<selectionOrder>ORIGINAL</selectionOrder>
</changeMoveSelector>
<acceptor>
<entityTabuSize>5</entityTabuSize>
</acceptor>
<forager>
</forager>
</localSearch>
<localSearch>
<changeMoveSelector>
<entitySelector>
... <!-- Normal selector properties -->
<entityClass>com.aps.hf.domain.MachineStageSecond</entityClass>
</entitySelector>
<selectionOrder>ORIGINAL</selectionOrder>
</changeMoveSelector>
<acceptor>
<entityTabuSize>5</entityTabuSize>
</acceptor>
<forager>
</forager>
</localSearch>
</solver>
Is the problem caused by two entity calsses or queued varaiables?
Thanks a lot ~
Upvotes: 0
Views: 238
Reputation: 27312
Cases with multiple entity classes (that each have at least one genuine (=non-shadow) planning variable) are difficult and rare.
@PlanningListVariable
is not yet compatible with multiple entity classes.
Upvotes: 3