timefold-solver icon indicating copy to clipboard operation
timefold-solver copied to clipboard

Declarative Shadow Variables: Struggles with overridden entities

Open triceo opened this issue 7 months ago • 0 comments

Consider a situation which occurs in the old implementation of CVRPTW:

  • Customer does not have arrivalTime. It doesn't need it, because it doesn't understand time windows.
  • TimeWindowedCustomer extends Customer and brings arrivalTime variable.
  • Customer has previousCustomer shadow, which TimeWindowedCustomer needs to compute its arrivalTime. Therefore this needs to be a source.

This currently results in an exception, because TimeWindowedCustomer doesn't see previousCustomer.arrivalTime, because previousCustomer is Customer and not TimeWindowedCustomer.

Attempts to solve this by overriding getter/setter for previousCustomer on TimeWindowedCustomer to provide TimeWindowedCustomer only results in a different runtime exception.

The issue will be resolved when the following code can be migrated to DSV, without changing the data model:

  • https://github.com/TimefoldAI/timefold-solver-benchmarks/tree/main/src/main/java/ai/timefold/solver/benchmarks/examples/vehiclerouting
  • https://github.com/TimefoldAI/timefold-solver-benchmarks/tree/main/src/main/java/ai/timefold/solver/benchmarks/examples/examination

triceo avatar Apr 25 '25 07:04 triceo