Skip to content

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

triceo
Copy link
Collaborator

@triceo triceo commented Jun 23, 2025

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.

@triceo triceo changed the title chore: Move streams allow value ranges on entities chore: Move streams basic variables allow value ranges on entities Jun 24, 2025
@triceo triceo marked this pull request as ready for review June 24, 2025 10:22
@triceo triceo requested review from Copilot and zepfred June 24, 2025 10:22
@triceo triceo added this to the v1.24.0 milestone Jun 24, 2025
@triceo triceo self-assigned this Jun 24, 2025
Copy link

@Copilot Copilot AI left a 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) {

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()) {
Copy link
Contributor

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?

Copy link
Contributor

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,
Copy link
Contributor

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.

…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>
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
43.6% Coverage on New Code (required ≥ 70%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants