feat: add replaceValue... methods to MutableSolutionView#2180
feat: add replaceValue... methods to MutableSolutionView#2180triceo wants to merge 6 commits intoTimefoldAI:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes moving and swapping elements inside planning list variables in MoveDirector, aiming to reduce per-move overhead on the solver hot path.
Changes:
- Introduces a
moveInList(...)helper that selects betweenCollections.rotateandremove+addbased on move distance/position. - Updates
moveValueInList(...)to use the new helper and return the moved value via the list after mutation. - Replaces manual swap logic with
Collections.swap(...)inswapValuesInList(...).
core/src/main/java/ai/timefold/solver/core/impl/move/MoveDirector.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/move/MoveDirector.java
Outdated
Show resolved
Hide resolved
Christopher-Chianelli
left a comment
There was a problem hiding this comment.
LGTM when tests are green.
core/src/main/java/ai/timefold/solver/core/impl/move/MoveDirector.java
Outdated
Show resolved
Hide resolved
|
@Christopher-Chianelli Since I was already here, I decided to implement a feature request from the models. Please re-review, new code was added. @winklerm Was this what you had in mind? |
core/src/main/java/ai/timefold/solver/core/impl/move/MoveDirector.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/preview/api/move/MutableSolutionView.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/preview/api/move/MutableSolutionView.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/preview/api/move/MutableSolutionView.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/preview/api/move/MutableSolutionView.java
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/preview/api/move/MutableSolutionView.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/preview/api/move/MutableSolutionView.java
Outdated
Show resolved
Hide resolved
…tableSolutionView.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
core/src/main/java/ai/timefold/solver/core/preview/api/move/MutableSolutionView.java
Show resolved
Hide resolved
|
| * while the sourceEntity's list size remains unchanged. | ||
| * | ||
| * @param variableMetaModel Describes the variable to be changed. | ||
| * @param sourceEntity The entity in which the value at {@code sourceIndex} will be replaced (overwritten). |
There was a problem hiding this comment.
Q: I would expect destinationEntity and destinationIndex instead of sourceEntity and sourceIndex, but might be just my personal preference.
Yes, thank you very much!! |



In addition to moveValue...