-
Notifications
You must be signed in to change notification settings - Fork 177
chore: improve MutableSolutionView API around list variables #2057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
|
Tagging @Christopher-Chianelli for review because I had to touch the multi-stage move. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
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
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/preview/api/move/MutableSolutionView.java
Outdated
Show resolved
Hide resolved
zepfred
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. My only suggestion is to include tests for scenarios where the source and destination entities are the same, as well as for the indexes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
winklerm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, that is very helpful!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
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/MoveRunner.java
Outdated
Show resolved
Hide resolved
|
Taking it back to draft again, because it still doesn't work right. |
| externalScoreDirector.beforeListVariableChanged(variableDescriptor, destinationEntity, destinationIndex, | ||
| destinationIndex + 1); | ||
| var actualOldValue = variableDescriptor.setElement(destinationEntity, destinationIndex, planningValue); | ||
| if (oldValue != actualOldValue) { | ||
| throw new IllegalStateException( | ||
| "Impossible state: The value (%s) at index (%d) of entity (%s) is not as expected (%s)." | ||
| .formatted(actualOldValue, destinationIndex, destinationEntity, oldValue)); | ||
| } | ||
| externalScoreDirector.afterListVariableChanged(variableDescriptor, destinationEntity, destinationIndex, | ||
| destinationIndex + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These notifications negate the performance benefit of this approach.
We only replace an element at a given place in the list, meaning nothing in the list needs to move back or forth; yet, these variable change notifications will still move things in the list.
I wonder if it could somehow be improved...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
core/src/main/java/ai/timefold/solver/core/preview/api/move/MutableSolutionView.java
Show resolved
Hide resolved
…oving and swapping items
|



Updates Javadocs of several
MutableSolutionViewmethods to better reflect the actual behavior.Also introduces new
assignValueoptions to support some corner cases.Adds plenty of test coverage for each.