Skip to content

docs: document nearby selection for basic variables in move selector reference#2362

Open
mvanhorn wants to merge 1 commit into
TimefoldAI:mainfrom
mvanhorn:fix/2292-nearby-selection-basic-variables
Open

docs: document nearby selection for basic variables in move selector reference#2362
mvanhorn wants to merge 1 commit into
TimefoldAI:mainfrom
mvanhorn:fix/2292-nearby-selection-basic-variables

Conversation

@mvanhorn

Copy link
Copy Markdown

Summary

The Move Selector Reference now documents nearby selection for basic planning variables: what origin and destination mean outside of list variables, and the advanced XML configuration for wiring nearbySelection into changeMoveSelector and swapMoveSelector. This covers the part of #2292 that stayed open after the heading fix.

Why this matters

#2292 was reopened by @triceo with the note that "the nearby part was not resolved". The nearby selection section of move-selector-reference.adoc only described NearbyDistanceMeter semantics and XML configuration for list variables, while the surrounding text ("In a nutshell, when nearby selection is used in a list move selector, ...") implies a basic-variable counterpart that the page never had. Anyone configuring nearby selection on a basic variable model had to reverse-engineer the selector configs to find the right XML shape.

Testing

  • The new subsection mirrors the structure and anchor conventions of the existing "Nearby selection with a list variable" subsection, so no new xref targets or duplicate anchors are introduced.
  • XML element names in the examples (nearbySelection, originEntitySelector, mimicSelectorRef, nearbyDistanceMeterClass) were checked against the selector config classes under core/src/main/java/ai/timefold/solver/core/config/heuristic/selector/.

Fixes #2292

@triceo

triceo commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Thanks for contributing, @mvanhorn !
Please review for correctness, @zepfred.

@triceo triceo modified the milestone: v2.3.0 Jun 12, 2026

In a nutshell, when nearby selection is used in a list move selector,
`Origin_` is always a planning value (for example `Customer`)
In a nutshell, the `Origin_` type follows the selector that is mimicked by the `nearbySelection` configuration,

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.

The paragraph can be simplified. I was thinking of something like this:

In a nutshell, when nearby selection is applied, the `Origin_` and `Destination_` types are determined by the relevant selectors within the `nearbySelection` configuration. For a basic variable, `Origin_` is defined by the planning entity of the nearby definition, while `Destination_` can be either a planning value or a planning entity. As for a list variable, `Origin_` is always a planning value (for example `Customer`),
but `Destination_` can be either a planning value or a planning entity.
That means that in VRP the distance meter must be able to handle both `Customer` and `Vehicle` as the `Destination_` argument:

involving the generation of the distance matrix and sorting operations without taking advantage of the feature.
====

==== Nearby selection with a basic variable

@zepfred zepfred Jun 12, 2026

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.

Please add a section ID so it can be referenced in the introduction paragraph when mentioning the basic variables.

</unionMoveSelector>
----

==== Nearby selection with a list variable

@zepfred zepfred Jun 12, 2026

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.

Please add a section ID so it can be referenced in the introduction paragraph when mentioning the list variables.

Change with Nearby,
and Swap with Nearby.

For a model that mixes basic and list variables,

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.

Please add the following paragraph as an [IMPORTANT] block.

add a `nearbySelection` element in the `valueSelector` of a `changeMoveSelector`
or in the `secondaryEntitySelector` of a `swapMoveSelector`,
and use xref:optimization-algorithms/move-selector-reference.adoc#mimicSelection[mimic selection]
to specify which entity should be the origin of the distance calculation.

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.

Suggested change
to specify which entity should be the origin of the distance calculation.
to specify which entity should be nearby the selection.

to specify which entity should be the origin of the distance calculation.

For a `changeMoveSelector`,
`Origin_` is the entity selected by the mimicking `entitySelector`

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.

Suggested change
`Origin_` is the entity selected by the mimicking `entitySelector`
`Origin_` is the entity selected


For a `changeMoveSelector`,
`Origin_` is the entity selected by the mimicking `entitySelector`
and `Destination_` is the planning value selected by the `valueSelector`.

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.

Suggested change
and `Destination_` is the planning value selected by the `valueSelector`.
and `Destination_` is the nearby planning value selected by the `valueSelector`.

`Origin_` is the entity selected by the mimicking `entitySelector`
and `Destination_` is the planning value selected by the `valueSelector`.
For a `swapMoveSelector`,
`Origin_` is the entity selected by the mimicking `entitySelector`

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.

Suggested change
`Origin_` is the entity selected by the mimicking `entitySelector`
both `Origin_` and `Destination_` are planning entities.

and `Destination_` is the planning value selected by the `valueSelector`.
For a `swapMoveSelector`,
`Origin_` is the entity selected by the mimicking `entitySelector`
and `Destination_` is the other planning entity selected by the `secondaryEntitySelector`.

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.

Suggested change
and `Destination_` is the other planning entity selected by the `secondaryEntitySelector`.
The `Destination_` is determined by the configuration setting `secondaryEntitySelector`.

For a `swapMoveSelector`,
`Origin_` is the entity selected by the mimicking `entitySelector`
and `Destination_` is the other planning entity selected by the `secondaryEntitySelector`.
If one distance meter is reused for both selectors,

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.

Suggested change
If one distance meter is reused for both selectors,

`Origin_` is the entity selected by the mimicking `entitySelector`
and `Destination_` is the other planning entity selected by the `secondaryEntitySelector`.
If one distance meter is reused for both selectors,
its `Destination_` type must accept both destination types.

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.

Suggested change
its `Destination_` type must accept both destination types.

<nearbyDistanceMeterClass>org.acme.schooltimetabling.domain.solver.nearby.LectureNearbyDistanceMeter</nearbyDistanceMeterClass>
</nearbySelection>
</secondaryEntitySelector>
<variableNameIncludes>

@zepfred zepfred Jun 12, 2026

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.

Let's simplify the example by removing the node variableNameIncludes.

@zepfred zepfred 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.

Thank you for your contribution, @mvanhorn. I have a few minor comments before I can approve it.

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.

Section on Nearby Selection for basic variables is missing and truncated

3 participants