public class SingleSwapNeighbourhood extends SubsetNeighbourhood
A subset neighbourhood that generates swap moves only (see
SwapMove). A swap move is a subtype of
SubsetMove. When applying swap moves generated by this neighbourhood to a given subset solution, the set
of selected IDs will always remain of the same size. Therefore, this neighbourhood is only suited for fixed size
subset selection. If desired, a set of fixed IDs can be provided which are not allowed to be swapped.
Note that this neighbourhood is thread-safe: it can be safely used to concurrently generate moves in different searches running in separate threads.
|Constructor and Description|
Creates a basic single swap neighbourhood.
Creates a single swap neighbourhood with a given set of fixed IDs which are not allowed to be swapped.
|Modifier and Type||Method and Description|
Generates a list of all possible swap moves that transform the given subset solution by removing a single ID from the current selection and replacing it with a new ID which is currently not selected.
Generates a random swap move for the given subset solution that removes a single ID from the set of currently selected IDs, and replaces it with a random ID taken from the set of currently unselected IDs.
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
fixedIDs- set of fixed IDs which are not allowed to be swapped
public SubsetMove getRandomMove(SubsetSolution solution, Random rnd)
solution- solution for which a random swap move is generated
rnd- source of randomness used to generate random move
nullif no swap move can be generated
public List<SubsetMove> getAllMoves(SubsetSolution solution)
solution- solution for which all possible swap moves are generated
Copyright © 2016. All rights reserved.