refactor: ScoreDirector is no longer public#2129
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request refactors the ScoreDirector from public API to internal implementation as part of Timefold Solver 2.0. The changes involve moving ScoreDirector from ai.timefold.solver.core.api.score.director to ai.timefold.solver.core.impl.score.director, and introducing a new PhaseCommandContext interface to replace the direct use of ScoreDirector in the public API. This is a significant breaking change that improves API encapsulation.
Changes:
- ScoreDirector moved from public API to internal implementation package
- PhaseCommand interface refactored to use PhaseCommandContext instead of ScoreDirector and BooleanSupplier parameters
- SolutionPartitioner.splitWorkingSolution() signature changed to accept Solution_ instead of ScoreDirector<Solution_>
- Documentation updated to reflect new API patterns and remove deprecated content
- Test domain classes updated (comparator/factory naming consistency improvements)
- MoveDirector enhanced with new assignValuesAndAdd method and executeTemporary variants
Reviewed changes
Copilot reviewed 123 out of 123 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/main/java/ai/timefold/solver/core/impl/score/director/ScoreDirector.java | Moved from api package to impl package, marked as non-public API |
| core/src/main/java/ai/timefold/solver/core/api/solver/phase/PhaseCommand.java | Interface refactored to use PhaseCommandContext parameter |
| core/src/main/java/ai/timefold/solver/core/api/solver/phase/PhaseCommandContext.java | New interface providing access to working solution and move execution |
| core/src/main/java/ai/timefold/solver/core/impl/phase/custom/DefaultPhaseCommandContext.java | Implementation of PhaseCommandContext |
| core/src/main/java/ai/timefold/solver/core/impl/partitionedsearch/partitioner/SolutionPartitioner.java | Interface updated to remove ScoreDirector dependency |
| core/src/main/java/ai/timefold/solver/core/impl/move/MoveDirector.java | Enhanced with new assignValuesAndAdd method and executeTemporary variants |
| docs/src/modules/ROOT/pages/optimization-algorithms/overview.adoc | Updated PhaseCommand documentation with new API |
| docs/src/modules/ROOT/pages/responding-to-change/responding-to-change.adoc | Removed deprecated PinningFilter section, updated ProblemChange references |
| docs/src/modules/ROOT/pages/constraints-and-score/constraint-configuration.adoc | Removed deprecated constraint configuration section |
| Multiple test files | Updated PhaseCommand implementations to use new API, comparator/factory naming improvements |
| Multiple impl files | Updated imports from api.score.director to impl.score.director |
docs/src/modules/ROOT/pages/optimization-algorithms/overview.adoc
Outdated
Show resolved
Hide resolved
docs/src/modules/ROOT/pages/optimization-algorithms/overview.adoc
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/domain/solution/PlanningEntityProperty.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/move/MoveDirector.java
Outdated
Show resolved
Hide resolved
f3948c7 to
903c988
Compare
903c988 to
012ee2e
Compare
core/src/test/java/ai/timefold/solver/core/impl/solver/SolverMetricsIT.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/solver/phase/PhaseCommandContext.java
Outdated
Show resolved
Hide resolved
012ee2e to
b1a2c0b
Compare
Christopher-Chianelli
left a comment
There was a problem hiding this comment.
I dislike renaming Rebaser to Lookup; the methods are more awkward, and I believe some changes should be made; in particular, the lookup/rebase method should not have "return null if does not exist" method, and instead I propose these two methods:
@NullMarked
interface Rebaser {
@Nullable
<Type_> rebase(@Nullable Type_ toRebase);
<Type_> rebaseExisting(Type_ toRebase);
}Both methods fail fast if toRebase does not exist in the ScoreDirector. They only differ in one accepts null (and thus return a nullable), the other does not (and thus always return non-null).
core/src/main/java/ai/timefold/solver/core/api/solver/phase/PhaseCommandContext.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/domain/entity/descriptor/EntityDescriptor.java
Outdated
Show resolved
Hide resolved
...ld/solver/core/impl/heuristic/selector/move/generic/list/kopt/SelectorBasedKOptListMove.java
Show resolved
Hide resolved
...imefold/solver/core/impl/heuristic/selector/move/generic/list/SelectorBasedListSwapMove.java
Outdated
Show resolved
Hide resolved
...efold/solver/core/impl/heuristic/selector/move/generic/list/SelectorBasedListChangeMove.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/preview/api/move/builtin/ListAssignMove.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/preview/api/move/builtin/ListChangeMove.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/preview/api/move/builtin/ListUnassignMove.java
Outdated
Show resolved
Hide resolved
...i/timefold/solver/core/impl/constructionheuristic/DefaultConstructionHeuristicPhaseTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/ai/timefold/solver/core/impl/move/MoveDirectorTest.java
Show resolved
Hide resolved
# Conflicts: # docs/TODO.md
b1a2c0b to
636e400
Compare
636e400 to
f3528b2
Compare
Christopher-Chianelli
left a comment
There was a problem hiding this comment.
I strongly disagree with erroring on unamed package; it forces the user to put classes inside a package, making it unsuitable for defining classes in a scripting context (such as jshell). Why does this matter to us? Rest of changes LGTM.
core/src/main/java/ai/timefold/solver/core/api/solver/change/ProblemChangeDirector.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/domain/entity/descriptor/EntityDescriptor.java
Outdated
Show resolved
Hide resolved
f3528b2 to
f2f2ddd
Compare
|



No description provided.