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

Design new VariableListener internal API to support efficient updates of list variable changes

XMLWordPrintable

    • Icon: Story Story
    • Resolution: Done
    • Icon: Critical Critical
    • 8.22.0.Final
    • None
    • optaplanner-core
    • None
    • 2021 Week 46-48 (from Nov 15), 2022 Week 05-07 (from Jan 31), 2022 Week 08-10 (from Feb 21), 2022 Week 11-13 (from Mar 14), 2022 Week 14-16 (from Apr 4), 2022 Week 17-19 (from Apr 25)
    • 13
    • NEW
    • NEW

      The index and inverseRelation shadow variables need to be updated when the list variable is changed by a move, including change, swap, assign and unassign moves.

      For example, in order to avoid score corruption during unassign move, the removed element's shadow variables need to be unset.

      Currently, the before/afterVariableChanged methods only receive the entity instance, whose list variable is being changed. The information about which element is being moved is missing. Therefore we unset index and inverse relation shadow variables of all elements in the list before variable changes and then reset them after the change is done. This is highly inefficient.

      Performance discussions:

      If the index at which the change occurs was part of the before/afterVariableChanged notification method, then we'd be able to eliminate a lot of unnecessary shadow variable updates on elements that are not affected by the change.

      The new ListVariableListener API should also work for custom shadow variables that have a genuine list variable as a source. Example: StartTimeUpdatingVariableListener implements ListVariableListener.

            jlocker Jiří Locker
            jlocker Jiří Locker
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: