public class IDBasedSubsetTabuMemory extends Object implements TabuMemory<SubsetSolution>
SubsetMove
. The tabu memory casts all received moves to this specific type and throws
an IncompatibleTabuMemoryException
if the cast fails.Constructor and Description |
---|
IDBasedSubsetTabuMemory(int size)
Creates an ID based subset tabu memory with specified size.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the tabu memory.
|
boolean |
isTabu(Move<? super SubsetSolution> move,
SubsetSolution currentSolution)
A move is considered tabu if any involved ID (added or deleted) is currently contained in the tabu memory.
|
void |
registerVisitedSolution(SubsetSolution visitedSolution,
Move<? super SubsetSolution> appliedMove)
Registers an applied subset move by storing all involved IDs (added or deleted) in the tabu memory.
|
public IDBasedSubsetTabuMemory(int size)
size
- memory size (strictly positive)IllegalArgumentException
- if size
is not strictly positivepublic boolean isTabu(Move<? super SubsetSolution> move, SubsetSolution currentSolution)
SubsetMove
, else an
IncompatibleTabuMemoryException
will be thrown. Note that the argument currentSolution
is not used here, because the move itself contains all necessary information, and may be null
.isTabu
in interface TabuMemory<SubsetSolution>
move
- subset move to be applied to the current solution (required to be of type SubsetMove
)currentSolution
- current solution (not used here, allowed to be null
)true
if the current memory contains any ID which is added or deleted by the given moveIncompatibleTabuMemoryException
- if the given move is not of type SubsetMove
public void registerVisitedSolution(SubsetSolution visitedSolution, Move<? super SubsetSolution> appliedMove)
SubsetMove
, else an IncompatibleTabuMemoryException
will be thrown.
The argument visitedSolution
is ignored, as the applied move contains all necessary information, and
may be null
. If appliedMove
is null
, calling this method does not have any
effect.registerVisitedSolution
in interface TabuMemory<SubsetSolution>
visitedSolution
- newly visited solution (not used here, allowed be null
)appliedMove
- applied move of which all involved IDs are stored in the tabu memoryIncompatibleTabuMemoryException
- if the given move is not of type SubsetMove
public void clear()
clear
in interface TabuMemory<SubsetSolution>
Copyright © 2016. All rights reserved.