Skip to content

Neighborhoods: finishing touches#2010

Merged
triceo merged 3 commits intoTimefoldAI:mainfrom
triceo:moves
Jan 13, 2026
Merged

Neighborhoods: finishing touches#2010
triceo merged 3 commits intoTimefoldAI:mainfrom
triceo:moves

Conversation

@triceo
Copy link
Copy Markdown
Collaborator

@triceo triceo commented Jan 11, 2026

The PR has 3 distinct parts:

  • First commit introduces the default neighborhood provider, allowing for easier co-existence between move selectors and neighborhoods.
  • Second commit significantly increases performance of neighborhoods by not materializing the lists in indexers if not absolutely necessary.
  • Third commit fixes a critical bug when neighborhoods would not be notified of all changes to the solution. This potentially also improves performance of neighborhoods, since it scopes which updates neighborhoods gets to see, but performance is secondary in this respect.

The 3 commits require each other to function, therefore they are provided as a single PR. But they will be merged without squashing.

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 pull request contains finishing touches for the Neighborhoods API feature, focusing on simplifications, optimizations, and better default behavior.

Changes:

  • Removed planning ID-based duplicate filtering from swap move providers to simplify implementation and improve performance
  • Added a default neighborhood provider that automatically provides change and swap moves when the Neighborhoods API is enabled
  • Refactored indexer infrastructure to support both iteration and random access patterns more efficiently

Reviewed changes

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

Show a summary per file
File Description
docs/src/modules/ROOT/pages/optimization-algorithms/neighborhoods.adoc Updated documentation to clarify default neighborhood behavior and future plans
core/src/test/java/ai/timefold/solver/core/preview/api/move/builtin/SwapMoveProviderTest.java Updated tests to expect duplicate swap moves (A<>B and B<>A)
core/src/test/java/ai/timefold/solver/core/preview/api/move/builtin/ListSwapMoveProviderTest.java Updated tests to expect duplicate swap moves
core/src/test/java/ai/timefold/solver/core/impl/solver/DefaultSolverTest.java Fixed exception type and added test for default neighborhood provider
core/src/test/java/ai/timefold/solver/core/impl/bavet/common/index/EqualsAndComparisonIndexerTest.java Added test for random access indexer functionality
core/src/test/java/ai/timefold/solver/core/impl/neighborhood/stream/enumerating/common/SelectionProbabilityTest.java Refactored to use new ElementAccessor interface
core/src/main/java/ai/timefold/solver/core/preview/api/move/builtin/SwapMoveProvider.java Removed planning ID logic, allowing duplicate swaps for simplicity and performance
core/src/main/java/ai/timefold/solver/core/preview/api/move/builtin/ListSwapMoveProvider.java Removed planning ID logic and simplified type parameters
core/src/main/java/ai/timefold/solver/core/impl/neighborhood/DefaultNeighborhoodProvider.java New default provider for basic change and swap moves
core/src/main/java/ai/timefold/solver/core/impl/localsearch/DefaultLocalSearchPhaseFactory.java Added logic to use default neighborhood provider and improved validation
core/src/main/java/ai/timefold/solver/core/impl/heuristic/HeuristicConfigPolicy.java Added helper methods for checking preview feature enablement
core/src/main/java/ai/timefold/solver/core/impl/util/ElementAwareArrayList.java Added iterator() and get() methods for improved access patterns
core/src/main/java/ai/timefold/solver/core/impl/neighborhood/stream/enumerating/* Refactored to support storing right sequences in tuple stores for memory efficiency
core/src/main/java/ai/timefold/solver/core/impl/neighborhood/stream/enumerating/common/ElementAccessor.java New interface abstracting element access for lists and indexers
core/src/main/java/ai/timefold/solver/core/impl/neighborhood/stream/enumerating/common/ListBasedElementAccessor.java List-based implementation of ElementAccessor
core/src/main/java/ai/timefold/solver/core/impl/neighborhood/stream/enumerating/common/IndexerBasedElementAccessor.java Indexer-based implementation of ElementAccessor
core/src/main/java/ai/timefold/solver/core/impl/neighborhood/stream/BiRandomMoveIterator.java Optimized to store sequences in tuple stores instead of separate map
core/src/main/java/ai/timefold/solver/core/impl/bavet/common/index/* Enhanced indexer API to support both iteration and random access

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/src/main/java/ai/timefold/solver/core/impl/move/MoveDirector.java Outdated
Copy link
Copy Markdown
Contributor

@zepfred zepfred left a comment

Choose a reason for hiding this comment

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

Looks great to me once the final comments are resolved!

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link
Copy Markdown

@triceo triceo merged commit 02e2c8b into TimefoldAI:main Jan 13, 2026
33 of 34 checks passed
@triceo triceo deleted the moves branch January 13, 2026 16:58
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.

4 participants