Survey finding from the #946–#951 refactor sweep, verified against current main. Scope was narrowed after verification.
Background
GreedyBasedOptimizationStrategy already implements the optimize_tasks() outer loop as a template method (dict(existing) → OptimizeResult → _sort_tasks() → per-task _allocate_task()/record). Greedy / PriorityFirst / EarliestDeadline / DependencyAware already derive from it and only override _sort_tasks().
Problem (verified, narrowed scope)
BackwardOptimizationStrategy and BalancedOptimizationStrategy re-implement the identical outer loop instead of inheriting it. Their optimize_tasks() bodies are essentially line-for-line identical to the GreedyBased template (even comments match), despite already having their own _sort_tasks / _allocate_task.
Proposal
Make Backward and Balanced extend GreedyBasedOptimizationStrategy and drop their duplicated optimize_tasks(), overriding only the sort/allocate hooks. Low risk, removes two full copies of the outer loop.
Out of scope
The original survey suggested templating all 9 strategies. Verification showed this does not hold:
RoundRobin distributes per-day across active tasks — not a per-task prepare→allocate→record loop.
Genetic / MonteCarlo are meta-strategies that call GreedyOptimizationStrategy._allocate_task internally to search orderings; their outer loop is search order → greedy allocate → fitness.
These three do not fit the _sort_tasks/_allocate_task template and should be left alone here. (A separate "reuse greedy allocation in meta-strategies" cleanup could be considered independently.)
Survey finding from the #946–#951 refactor sweep, verified against current
main. Scope was narrowed after verification.Background
GreedyBasedOptimizationStrategyalready implements theoptimize_tasks()outer loop as a template method (dict(existing)→OptimizeResult→_sort_tasks()→ per-task_allocate_task()/record). Greedy / PriorityFirst / EarliestDeadline / DependencyAware already derive from it and only override_sort_tasks().Problem (verified, narrowed scope)
BackwardOptimizationStrategyandBalancedOptimizationStrategyre-implement the identical outer loop instead of inheriting it. Theiroptimize_tasks()bodies are essentially line-for-line identical to the GreedyBased template (even comments match), despite already having their own_sort_tasks/_allocate_task.Proposal
Make
BackwardandBalancedextendGreedyBasedOptimizationStrategyand drop their duplicatedoptimize_tasks(), overriding only the sort/allocate hooks. Low risk, removes two full copies of the outer loop.Out of scope
The original survey suggested templating all 9 strategies. Verification showed this does not hold:
RoundRobindistributes per-day across active tasks — not a per-taskprepare→allocate→recordloop.Genetic/MonteCarloare meta-strategies that callGreedyOptimizationStrategy._allocate_taskinternally to search orderings; their outer loop issearch order → greedy allocate → fitness.These three do not fit the
_sort_tasks/_allocate_tasktemplate and should be left alone here. (A separate "reuse greedy allocation in meta-strategies" cleanup could be considered independently.)