public class SingleDeletionNeighbourhood extends SubsetNeighbourhood
A subset neighbourhood that generates deletion moves only (see DeletionMove
). A deletion move is a subtype
of SubsetMove
that removes a single ID from the selection of a subset solution. If desired, a set of fixed
IDs can be provided which are not allowed to be removed from the selection. Also, a size limit can be imposed so that
no moves are generated when the current solution has minimum size.
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 |
---|
SingleDeletionNeighbourhood()
Create a single deletion neighbourhood without minimum subset size.
|
SingleDeletionNeighbourhood(int minSubsetSize)
Create a single deletion neighbourhood with a given minimum subset size.
|
SingleDeletionNeighbourhood(int minSubsetSize,
Set<Integer> fixedIDs)
Create a single deletion neighbourhood with a given minimum subset size
and a set of fixed IDs which are not allowed to be deselected.
|
Modifier and Type | Method and Description |
---|---|
List<SubsetMove> |
getAllMoves(SubsetSolution solution)
Generates a list of all possible deletion moves that remove a single ID from the selection of a given
subset solution.
|
int |
getMinSubsetSize()
Get the minimum subset size.
|
SubsetMove |
getRandomMove(SubsetSolution solution,
Random rnd)
Generates a random deletion move for the given subset solution that removes a single ID from the selection.
|
getAddCandidates, getRemoveCandidates
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getRandomMove
public SingleDeletionNeighbourhood()
public SingleDeletionNeighbourhood(int minSubsetSize)
minSubsetSize
- minimum subset size (≥ 0)IllegalArgumentException
- if minimum subset size is negativepublic SingleDeletionNeighbourhood(int minSubsetSize, Set<Integer> fixedIDs)
minSubsetSize
- minimum subset size (≥ 0)fixedIDs
- set of fixed IDs which are not allowed to be removed from the selectionIllegalArgumentException
- if minimum subset size is negativepublic int getMinSubsetSize()
public SubsetMove getRandomMove(SubsetSolution solution, Random rnd)
null
is returned.solution
- solution for which a random deletion 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 deletion moves are generatedCopyright © 2016. All rights reserved.