heyif
heyif

Reputation: 41

optaplanner: Why no entityClass (null) configured and because there are multiple in the entityClassSet?

I am doing a production schedule program with optaplanner, it has two planning entity, Task & PDItem, as below:

Hi Optaplanner Team: I am doing a production schedule program with optaplanner, it has two planning entity, Task & PDItem, as below:

@PlanningEntity(difficultyComparatorClass = TaskDifficultyComparator.class)
 public class Task {


  private Integer waitting_time;   //planning variable


  @PlanningVariable(valueRangeProviderRefs = {"wtRange"})   
      public Integer getWaitting_time() {

                return waitting_time;
           }


   @ValueRangeProvider(id = "wtRange")
      public CountableValueRange<Integer> WaitTimeRange_v2() {
         return ValueRangeFactory.createIntValueRange(this.searchRangeDown,this.searchRange+1);

            }




      @PlanningEntity(difficultyComparatorClass = TaskDifficultyComparator.class)
      public class PDItem {

       private DyeMachineType machine_type; //planning variable


      @PlanningVariable(valueRangeProviderRefs = {"macRange"})  
        public DyeMachineType getMachine_type() {
         return machine_type;
        }


     @ValueRangeProvider(id = "macRange")
       public ArrayList<DyeMachineType> getDyemachinetype_list() {
            return this.dyemachinetype_list;
          }

but when I start the program, it show as below:

Exception in thread "main" java.lang.IllegalArgumentException: The config (QueuedEntityPlacerConfig(null, null)) has no entityClass (null) configured and because there are multiple in the entityClassSet ([class Planning_v3.Domain.Task, class Planning_v3.Domain.PDItem]), it can not be deduced automatically. at org.optaplanner.core.config.AbstractConfig.deduceEntityDescriptor(AbstractConfig.java:86) at org.optaplanner.core.config.constructionheuristic.placer.QueuedEntityPlacerConfig.buildEntitySelectorConfig(QueuedEntityPlacerConfig.java:144) at org.optaplanner.core.config.constructionheuristic.placer.QueuedEntityPlacerConfig.buildEntityPlacer(QueuedEntityPlacerConfig.java:107) at org.optaplanner.core.config.constructionheuristic.placer.QueuedEntityPlacerConfig.buildEntityPlacer(QueuedEntityPlacerConfig.java:43) at org.optaplanner.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig.buildPhase(ConstructionHeuristicPhaseConfig.java:166) at org.optaplanner.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig.buildPhase(ConstructionHeuristicPhaseConfig.java:51) at org.optaplanner.core.config.solver.SolverConfig.buildPhaseList(SolverConfig.java:367) at org.optaplanner.core.config.solver.SolverConfig.buildSolver(SolverConfig.java:270) at org.optaplanner.core.impl.solver.AbstractSolverFactory.buildSolver(AbstractSolverFactory.java:61) at Planning_v3.APP.PlanningAPP3.main(PlanningAPP3.java:47)

Please adv your help!Thank you very much!

Please adv your help!Thank you very much!

Upvotes: 2

Views: 765

Answers (1)

Geoffrey De Smet
Geoffrey De Smet

Reputation: 27312

You currently have 2 classes with an @PlanningEntity annotation which also have at least one genuine @PlanningVariable (!= shadow variable). So you have 2 genuine planning entity classes (shadow entities don't count).

That is very uncommon. In most cases, if you design a good model, following the guidelines of this section in the docs, you will not end up with 2 genuine planning entity classes and save yourself a lot of pain.

That being said, there are cases for which it does make sense. (On first sight, your case doesn't seem to be one of those, read that guide first):

  • Some users still avoid it then with multi-stage planning - but that's often more because of the way the company is structured (see Conway's law) and to start with a simple project.
  • But if you do have 2 genuine planning entities, that's fine for OptaPlanner. But the algorithms need to be power-tweaked though, as explained in this chapter.

Upvotes: 4

Related Questions