public class DisjointMultiDeletionNeighbourhood extends SubsetNeighbourhood
A subset neighbourhood that generates moves which simultaneously remove a fixed number of items from the selection.
Generated moves are of type GeneralSubsetMove
, which is a subtype of SubsetMove
, and always only
remove IDs from the selection. If desired, a set of fixed IDs can be provided which are not allowed to be removed.
Also, a minimum size can be imposed so that it is guaranteed that the subset size will not drop below this minimum
after application of a move generated by this neighbourhood. It may happen to be impossible to perform the desired
number of deletions, e.g. because too few items are selected or because of the imposed minimum subset size. In such
case a lower number of items will be removed (as many as possible).
Note that a large amount of moves may be generated when the subset size increases. Therefore, this advanced neighbourhood should be used with care, especially in combination with searches that inspect all moves in every step. Furthermore, searches that inspect random moves may have few chances to find an improvement in case of a huge amount of possible neighbours.
This neighbourhood is thread-safe: it can be safely used to concurrently generate moves in different searches running in separate threads.
Constructor and Description |
---|
DisjointMultiDeletionNeighbourhood(int numDeletions)
Creates a disjoint multi deletion neighbourhood that simultaneously removes a fixed number of
IDs from the selection.
|
DisjointMultiDeletionNeighbourhood(int numDeletions,
int minSubsetSize)
Creates a disjoint multi deletion neighbourhood that simultaneously removes a fixed number of
IDs from the selection, taking into account that the subset size may not drop below the given minimum.
|
DisjointMultiDeletionNeighbourhood(int numDeletions,
int minSubsetSize,
Set<Integer> fixedIDs)
Creates a disjoint multi deletion neighbourhood that simultaneously removes a fixed number of
IDs from the selection, taking into account that the subset size may not drop below the given minimum
and that the given set of fixed IDs are not allowed to be deselected.
|
Modifier and Type | Method and Description |
---|---|
List<SubsetMove> |
getAllMoves(SubsetSolution solution)
Generates the list of all possible moves that perform \(k\) deletions, where \(k\) is the fixed number
specified at construction.
|
int |
getMinSubsetSize()
Get the minimum subset size specified at construction.
|
int |
getNumDeletions()
Get the fixed number of deletions performed by generated moves.
|
SubsetMove |
getRandomMove(SubsetSolution solution,
Random rnd)
Generates a move for the given subset solution that deselects a random subset of currently selected IDs.
|
getAddCandidates, getRemoveCandidates
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getRandomMove
public DisjointMultiDeletionNeighbourhood(int numDeletions)
numDeletions
is 1, this neighbourhood generates exactly the
same moves as the SingleDeletionNeighbourhood
so in such case it is advised to use the latter
neighbourhood which has been optimized for this specific scenario.numDeletions
- fixed number of removed IDs (> 0)IllegalArgumentException
- if numDeletions
is not strictly positivepublic DisjointMultiDeletionNeighbourhood(int numDeletions, int minSubsetSize)
numDeletions
is 1, this neighbourhood generates exactly the same moves as the
SingleDeletionNeighbourhood
so in such case it is advised to use the latter neighbourhood
which has been optimized for this specific scenario.numDeletions
- fixed number of removed IDs (> 0)minSubsetSize
- minimum subset size (≥ 0)IllegalArgumentException
- if numDeletions
is not strictly positive
or minSubsetSize
is negativepublic DisjointMultiDeletionNeighbourhood(int numDeletions, int minSubsetSize, Set<Integer> fixedIDs)
numDeletions
is 1, this neighbourhood generates exactly the same moves as the SingleDeletionNeighbourhood
so in such case it is advised to use the latter neighbourhood which has been optimized for this
specific scenario.numDeletions
- fixed number of removed IDs (> 0)minSubsetSize
- minimum subset size (≥ 0)fixedIDs
- set of fixed IDs which are not allowed to be removed from the selectionIllegalArgumentException
- if numDeletions
is not strictly positive
or minSubsetSize
is negativepublic int getNumDeletions()
public int getMinSubsetSize()
public SubsetMove getRandomMove(SubsetSolution solution, Random rnd)
null
is returned.solution
- solution for which a random multi deletion move is generatedrnd
- source of randomness used to generate random movenull
if no items can be removedpublic List<SubsetMove> getAllMoves(SubsetSolution solution)
Generates the list of all possible moves that perform \(k\) deletions, where \(k\) is the fixed number specified at construction. Note: taking into account the current number of selected items, the imposed minimum subset size (if set) and the fixed IDs (if any) may result in fewer deletions (as many as possible).
May return an empty list if no moves can be generated.
solution
- solution for which all possible multi deletion moves are generatedCopyright © 2016. All rights reserved.