1 year ago
#364366
Alastair
Maintaining a resource profile as a "Shadow Entity"
I'm trying to model a problem where I'm incrementally maintaining a cumulative resource consumption profile via a VariableListener. I'm using a chained model similar to the VRP examples. The chain anchor is a Worker and the following items are Tasks which have start times updated via the listener.
My current model has each Worker contain a reference to a WorkerProfile (which is effectively a wrapper around a TreeMap style structure). In the VariableListener I add / remove sections as Tasks shift in time / between workers.
Running in FULL_ASSERT mode I can see that I'm in encountering Score Corruption which I suspect is due to the fact these WorkerProfiles are being altered by a Listener but aren't marked as a Shadow Variable or PlanningEntity (the class is Cloneable and annotated with DeepPlanningClone)
The closest situation I've seen is in this question where the concept of a "Shadow Entity" is raised, but I've not seen any more detailed examples here, in the documentation or in the GitHub repos. Most VariableListener / ShadowVariable uses seem to be just altering a single primitive.
The docs example
@DeepPlanningClone
@CustomShadowVariable(...)
private Map<LocalDateTime, Integer> usedManHoursPerDayMap;
seems similar, but I can't see anything beyond this stub anywhere.
Is what I'm trying to do possible via the Shadow Variable / Variable Listener route? Where should these profiles "live"? Currently they are a field on the anchor Worker class.
When OptaPlanner restores the Best Solution will these entities be correctly restored automatically? Will I need to do anything (beyond basic thread safety) for OptaPlanner to be able to support using <moveThreadCount>AUTO</moveThreadCount>
(e.g. do they need a PlanningId?)
optaplanner
0 Answers
Your Answer