Skip to content

fix: restore support for null values in sortable value ranges#2238

Merged
triceo merged 2 commits intoTimefoldAI:mainfrom
zepfred:fix/null
Apr 15, 2026
Merged

fix: restore support for null values in sortable value ranges#2238
triceo merged 2 commits intoTimefoldAI:mainfrom
zepfred:fix/null

Conversation

@zepfred
Copy link
Copy Markdown
Contributor

@zepfred zepfred commented Apr 14, 2026

No description provided.

@zepfred zepfred marked this pull request as ready for review April 14, 2026 20:51
@zepfred zepfred requested a review from triceo as a code owner April 14, 2026 20:51
Copilot AI review requested due to automatic review settings April 14, 2026 20:51
Copy link
Copy Markdown
Contributor

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 adds coverage for scenarios where planning variables (basic and list) allow unassigned values while also using value sorting, ensuring the “unassigned/null” option is preserved through sorting and during construction heuristic solving.

Changes:

  • Fix NullAllowingValueRange.sort(...) to keep the null-allowing wrapper after sorting.
  • Add new test domain solution/entity pairs for sortable entities with allowsUnassigned / allowsUnassignedValues.
  • Extend construction heuristic tests to verify solvers can prefer leaving variables unassigned when constraints penalize assignments.

Reviewed changes

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

Show a summary per file
File Description
core/src/main/java/ai/timefold/solver/core/impl/domain/valuerange/NullAllowingValueRange.java Ensures sorting retains the null-allowing wrapper, keeping the unassigned option available.
core/src/test/java/ai/timefold/solver/core/impl/domain/valuerange/NullAllowingValueRangeTest.java Updates assertions to reflect null being present after sorting.
core/src/test/java/ai/timefold/solver/core/impl/constructionheuristic/DefaultConstructionHeuristicPhaseTest.java Adds constraint-stream-based tests verifying CH can keep basic/list variables unassigned when optimal.
core/src/test/java/ai/timefold/solver/core/testdomain/unassignedvar/sort/TestdataAllowsUnassignedSortableSolution.java New test solution for basic sortable entity with unassigned variable support.
core/src/test/java/ai/timefold/solver/core/testdomain/unassignedvar/sort/TestdataAllowsUnassignedSortableEntity.java New planning entity with @PlanningVariable(allowsUnassigned = true) and comparator sorting.
core/src/test/java/ai/timefold/solver/core/testdomain/list/unassignedvar/sort/TestdataAllowsUnassignedListSortableSolution.java New test solution for list-variable sortable entity with unassigned values support.
core/src/test/java/ai/timefold/solver/core/testdomain/list/unassignedvar/sort/TestdataAllowsUnassignedListSortableEntity.java New planning entity with @PlanningListVariable(allowsUnassignedValues = true) and comparator sorting.

@zepfred zepfred marked this pull request as draft April 15, 2026 00:22
@zepfred zepfred changed the title feat: add support for unassigned variables in sortable entities feat: add support for null values in sortable value ranges Apr 15, 2026
Copy link
Copy Markdown
Collaborator

@triceo triceo left a comment

Choose a reason for hiding this comment

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

LGTM after comments are resolved.

@triceo triceo added this to the v2.0.0 milestone Apr 15, 2026
@triceo triceo changed the title feat: add support for null values in sortable value ranges fix: restore support for null values in sortable value ranges Apr 15, 2026
@zepfred zepfred marked this pull request as ready for review April 15, 2026 12:48
Copilot AI review requested due to automatic review settings April 15, 2026 12:48
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

@sonarqubecloud
Copy link
Copy Markdown

@triceo triceo merged commit bd1be4b into TimefoldAI:main Apr 15, 2026
23 checks passed
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.

null not picked when using @PlanningVariable comparatorClass and allowUnassigned=true

3 participants