-
Notifications
You must be signed in to change notification settings - Fork 141
chore: Move streams basic variables allow value ranges on entities #1658
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
base: main
Are you sure you want to change the base?
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.
Pull Request Overview
This PR refactors the move streams for basic variable support and enhances handling of value ranges defined on entities. Key changes include modifications to test domains (e.g. incomplete value range generation), updates to move stream APIs (transitioning from the generic subpackage to the maybeapi subpackage and introducing the use of SolutionView), and adjustments in internal components (e.g. move repository and score director) to support these new patterns.
Reviewed Changes
Copilot reviewed 55 out of 55 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
core/src/test/** | Updated test domain classes to generate and handle incomplete value ranges on entities. |
core/src/main/java/ai/timefold/solver/core/impl/move/streams/** | Refactored move stream APIs to use SolutionView, added includeNull parameters, and migrated from the generic package to maybeapi. |
core/src/main/java/ai/timefold/solver/core/impl/score/director/** | Extended isValueInRange API support by leveraging the new value range state and SolutionView. |
core/src/main/java/ai/timefold/solver/core/impl/move/director/** | Integrated new isValueInRange behavior into the move director. |
Comments suppressed due to low confidence (2)
core/src/main/java/ai/timefold/solver/core/impl/move/streams/dataset/AbstractForEachDataStream.java:42
- Consider adding a comment clarifying that when the shouldIncludeNull flag is true, a null value is inserted into the node to represent an unassigned value. This will improve code clarity for future maintainers.
}
core/src/main/java/ai/timefold/solver/core/impl/move/streams/DefaultMoveStreamFactory.java:35
- Please add Javadoc for the 'includeNull' parameter to clearly describe its role in including a null value in the data stream. This will ensure consistent understanding of its purpose across similar factory methods.
public <A> UniDataStream<Solution_, A> enumerate(Class<A> sourceClass, boolean includeNull) {
.../ai/timefold/solver/core/impl/move/streams/maybeapi/generic/provider/ChangeMoveProvider.java
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/solver/DefaultSolverFactory.java
Show resolved
Hide resolved
public <Entity_, Value_> boolean isValueInRange(GenuineVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, | ||
@Nullable Entity_ entity, @Nullable Value_ value) { | ||
var valueRangeDescriptor = extractValueRangeDescriptor(variableMetaModel); | ||
if (entity == null && valueRangeDescriptor.isEntityIndependent()) { |
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.
Should it be !valueRangeDescriptor.isEntityIndependent()
instead?
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.
If that’s the case, I wonder why it isn’t failing.
|
||
protected AbstractForEachDataStream(DataStreamFactory<Solution_> dataStreamFactory, Class<A> forEachClass) { | ||
protected AbstractForEachDataStream(DataStreamFactory<Solution_> dataStreamFactory, Class<A> forEachClass, |
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.
We are implementing the builder pattern in some parts of the code. I wonder if we should adopt it as the default approach when there are three or more properties.
.../ai/timefold/solver/core/impl/move/streams/maybeapi/generic/provider/ChangeMoveProvider.java
Show resolved
Hide resolved
core/src/test/java/ai/timefold/solver/core/impl/move/streams/dataset/UniDatasetStreamTest.java
Show resolved
Hide resolved
core/src/test/java/ai/timefold/solver/core/impl/move/streams/dataset/UniDatasetStreamTest.java
Outdated
Show resolved
Hide resolved
...java/ai/timefold/solver/core/impl/move/streams/maybeapi/provider/ChangeMoveProviderTest.java
Show resolved
Hide resolved
…ataset/UniDatasetStreamTest.java Co-authored-by: Frederico Gonçalves <zepfred@users.noreply.github.com>
…ataset/UniDatasetStreamTest.java Co-authored-by: Frederico Gonçalves <zepfred@users.noreply.github.com>
|
The filtering during picking is refactored, so that the filter gets access to solution
and therefore can decide whether or not a particular value is or is not part of a value range.
Moves that do not fit in the value range can now be filtered out,
regardless whether the value range comes from a solution or from an entity.
We also implement a cache for value ranges, and thread it through the solver.
This cache will only be invalidated on-demand in situations where relevant information changes,
leading to best possible performance.
Code pertaining to the previous implementation is removed,
as the previous implementation only supported value ranges on solution.