public class SingleAdditionNeighbourhood extends SubsetNeighbourhood
A subset neighbourhood that generates addition moves only (see AdditionMove
). An addition move is a subtype
of SubsetMove
that adds a single ID to the selection of a subset solution. If desired, a set of fixed IDs
can be provided which are not allowed to be added to the selection. Also, a size limit can be imposed so that
no moves are generated when the current solution has maximum size.
Note that this neighbourhood is threadsafe: it can be safely used to concurrently generate moves in different searches running in separate threads.
Constructor and Description 

SingleAdditionNeighbourhood()
Create a single addition neighbourhood without maximum subset size.

SingleAdditionNeighbourhood(int maxSubsetSize)
Create a single addition neighbourhood with a given limit on the number of selected items
(maximum subset size).

SingleAdditionNeighbourhood(int maxSubsetSize,
Set<Integer> fixedIDs)
Create a single addition neighbourhood with a limit on the number of selected
items (subset size) and a given set of fixed IDs which are not allowed to be
selected.

Modifier and Type  Method and Description 

List<SubsetMove> 
getAllMoves(SubsetSolution solution)
Generates a list of all possible addition moves that add a single ID to the selection of a given
subset solution.

int 
getMaxSubsetSize()
Get the maximum subset size.

SubsetMove 
getRandomMove(SubsetSolution solution,
Random rnd)
Generates a random addition move for the given subset solution that adds a single ID to the selection.

getAddCandidates, getRemoveCandidates
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getRandomMove
public SingleAdditionNeighbourhood()
public SingleAdditionNeighbourhood(int maxSubsetSize)
maxSubsetSize
 maximum subset size (> 0)IllegalArgumentException
 if maximum subset size is not strictly positivepublic SingleAdditionNeighbourhood(int maxSubsetSize, Set<Integer> fixedIDs)
maxSubsetSize
 maximum subset size (> 0)fixedIDs
 set of fixed IDs which are not allowed to be added to the selectionIllegalArgumentException
 if maximum subset size is not strictly positivepublic int getMaxSubsetSize()
Integer.MAX_VALUE
.public SubsetMove getRandomMove(SubsetSolution solution, Random rnd)
null
is returned.solution
 solution for which a random addition move is generatedrnd
 source of randomness used to generate random movenull
if no move can be generatedpublic List<SubsetMove> getAllMoves(SubsetSolution solution)
solution
 solution for which all possible addition moves are generatedCopyright © 2016. All rights reserved.