Skip to content

perf: simplify how value ranges are built#2425

Merged
triceo merged 1 commit into
TimefoldAI:mainfrom
triceo:vr
Jun 26, 2026
Merged

perf: simplify how value ranges are built#2425
triceo merged 1 commit into
TimefoldAI:mainfrom
triceo:vr

Conversation

@triceo

@triceo triceo commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@triceo triceo requested a review from zepfred as a code owner June 26, 2026 07:35
Copilot AI review requested due to automatic review settings June 26, 2026 07:35
@triceo triceo self-assigned this Jun 26, 2026
@triceo triceo added this to the v2.3.0 milestone Jun 26, 2026

// Solution related fields
private @Nullable ValueRangeItem<Solution_, Entity_, ValueRange<Value_>, Value_> fromSolutionItem;
private @Nullable Map<Value_, Integer> fromSolutionValueIndexMap;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was only returned by a method that was never called...

return null;
}

private Map<Value_, Integer> getIndexMapFromSolution() {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... this method.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 improves performance of reachable-values construction by avoiding redundant processing when multiple entities share the same (deduplicated) value range, and it adds test coverage to prevent regressions in that scenario.

Changes:

  • Build reachable values by grouping entity indices per distinct ValueRange instance and processing each range once.
  • Simplify sorter delegation in getFromEntity(...) and tighten encapsulation of HashedValueRange.
  • Add a regression test for shared entity value ranges; modernize test code to use List.getFirst() (JDK 21).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
core/src/main/java/ai/timefold/solver/core/impl/score/director/ValueRangeState.java Groups entities by deduplicated ValueRange instance to avoid repeated bitset work while still registering reachability per entity.
core/src/test/java/ai/timefold/solver/core/impl/heuristic/selector/common/ReachableValuesTest.java Adds coverage ensuring entities sharing a value range are all registered as reachable, and co-values behave as expected.

Copilot AI review requested due to automatic review settings June 26, 2026 07:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 2 out of 2 changed files in this pull request and generated no new comments.

@sonarqubecloud

Copy link
Copy Markdown

@triceo triceo merged commit a835105 into TimefoldAI:main Jun 26, 2026
21 of 24 checks passed
@triceo triceo deleted the vr branch June 26, 2026 13:57
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.

3 participants