Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-834

Overwritten methods with(out) annotations on planning entity and solution classes should behave consistently (polymorfism)

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 7.0.0.Final
    • optaplanner-core
    • 2017 Week 24-25, 2017 Week 26-27, 2017 Week 28-29, 2017 Week 30-31, 2017 Week 32-33, 2017 Week 34-35, 2017 Week 36-37, 2017 Week 38-39, 2017 Week 40-41-42, 2017 Week 43-44, 2017 Week 45-46, 2017 Week 47-48, 2017 Week 49-50, 2017 Week 51-52, 2018 Week 01-02, 2018 Week 03-04
    • NEW
    • NEW

      Brain dump of meeting

      A) Subtyping

      A subclass of the planning entity can be used in runtime (plain Java subtyping).

      @PlanningEntity
      class AnimalEntity {
          private String name;
      
          @PlanningVariable(...)
          private Person owner;
      
      }
      
      class CatEntity extends AnimalEntity {
      
          private Collar collar;
      
      }
      

      B) 2nd variable - getter

      A subclass can add a second planning variable (requires different entity descriptor).

      @PlanningEntity
      class AnimalEntity {
          private String name;
      
          @PlanningVariable(...)
          private Person owner;
      
      }
      
      @PlanningEntity
      class DogEntity extends AnimalEntity {
      
          @PlanningVariable(...)
          private Hotel hotel;
      
      }
      

      C) 2nd variable - field

      @PlanningEntity
      class AnimalEntity {
          private String name;
      
          @PlanningVariable(...)
          public Person getOwner() {...}
      
      }
      
      @PlanningEntity
      class DogEntity extends AnimalEntity {
      
          @PlanningVariable(...)
          public Hotel getHotel() {...}
      
      }
      

      D) removing planning variable from the superclass

      @PlanningEntity
      class AnimalEntity {
          private String name;
      
          @PlanningVariable(...)
          public Person getOwner() {...}
      
      }
      
      @PlanningEntity
      class DogEntity extends AnimalEntity {
      
          @PlanningVariable(...)
          public Hotel getHotel() {...}
      
          public Person getOwner() {...} // What will happen?
      
      }
      
      • What happens in JPA?
      • What are the use cases?
        • 1) owner is a planning variable because it gets inherited
          => manually or through @Inherited on @PlanningVariable?
        • 2) owner is NOT a planning variable, because it gets reset

      Truth

      • only if @PlanningEntity is on class, then @PlanningVariable is recognized
        => probably something in docs (extends are supported but only if registered) -> Geof Action
        • We go with 1), so add @Inherited on @PVariable and all shadow vars etc ValueRange, etc etc
          and adjust code if needed
        • We need to have tests. twice one combo of each type:
      • PlanningSolution
        @ProblemFactCollectionProperty, ...
        @PlanningEntityCollectionProperty, ...
        @PlanningScore
        @ValueRangeProvider
      • PlanningEntity
        @PlanningVariable
        @CustomShadowVariable, @AnchorShadowVariable, and *ShadowVariable
        @ValueRangeProvider
      • @DeepPlanningClone => Is already @Inherited Should work in theory?
        we need this tests too (separate issue?)
        Which tests if A extends B?
      • if A has @PlanningVariable and B @ShadowVariable => fail fast (2 != anno's)
      • if A has @PlanningVariable and B @PlanningVariable => ok (exactly same anno's)
        => ok (not exactly same anno's)
      • if A has @PlanningVariable and B does not => works as planning var for A, but not B
      • if B has @PlanningVariable and A does not => works as planning var for A and B
      • Separate issue:
        Dog extends Animal, Cat extends Animal,
        Dog overwrite value range of @PlanningVariable of Animal
        entity list contains dogs and cats.
        -> is the dog's value ranges always used for dogs?

      Requirements

      • consistency between @PlanningSolution and @PlanningEntity
      class TestDataEntityParent { // give better name
        @PlanningVariable a();
        @CustomShadowVariable b();
        ...
      }
      
      TestDataInvalidDuplicateOverwrittenTestDataEntity extend TestDataEntityParent { // give better name
       @AnchorShadowVariable a(); // conflict
       ...
      }
      
      TestDataJustInheritingTestDataEntity extend TestDataEntityParent { // give better name
       a();
       ...
      }
      
      TestDataValidOverwrittingTestDataEntity extend TestDataEntityParent { // give better name
        @PlanningVariable a();
        ...
      }
      

              Unassigned Unassigned
              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: