Class DynHeurSet
public class DynHeurSet
extends java.lang.Object
Dynamic sets can be used within hyper-heuristics to manage the set of low-level heuristics available for the hyper-heuristic to select from. This set is called the active set which is typically a subset of the universal set that represents the set of all low-level heuristics in a problem domain.
A dynamic set changes during the search allowing different heuristics to enter and leave the active set at different phases during the search.
This dynamic set has a RunStat field to keep track of run-related
statistics/variables such as the elapsed time, the best solution value,
the improvement (deterioration) achieved (caused) by each heuristic and many more.
This dynamic set has a Update field which implements
the update strategy that defines the update condition (when
to update) and the update criterion (which heuristic to include in the active
set).
-
Field Summary
-
Constructor Summary
Constructors Constructor Description DynHeurSet() -
Method Summary
Modifier and Type Method Description java.util.List<java.lang.Integer>getActiveList()Returns the currently active set.intgetNumberOfRemove()Returns the number of times a removal strategy is triggered.intgetNumberOfResets()Returns the number of times the active set is reset to include all heuristics except for permanently removed heuristics.intgetNumberOfUpdates()Returns the number of updates performed by this dynamic sets.RunStatgetRunStatistics()Returns therunStatfield of this dynamic set.voidinit(double initValue)Initializes this dynamic heuristic set.voidrestart(double initValue)Indicates that a restart strategy is triggered in the hyper-heuristic.voidsetHeurList(int[] heurArray)Sets the universal set for this dynamic heuristic set.voidsetMaxTime(long maxTime)Sets the maximum computational time for this dynamic heuristic set.voidsetRunStat(RunStat runStat)Sets therunStatfield of this dynamic set.voidsetUpdate(Update update)Sets the update strategy for this dynamic set.java.util.List<java.lang.Integer>updateActiveList()Updates the active set from which the hyper-heuristic is allowed to choose if an update condition is satisfied and returns the currently active set.voidupdateHeurValue(int idx, double currentValue, double newValue, long duration)Updates the performance-related information of the heuristic stored at indexidxin the universal set of this dynamic set.
-
Field Details
-
Constructor Details
-
DynHeurSet
public DynHeurSet()
-
-
Method Details
-
setRunStat
Sets therunStatfield of this dynamic set.- Parameters:
runStat- records run-related information
-
setUpdate
Sets the update strategy for this dynamic set.- Parameters:
update- the update strategy used by this dynamic set
-
setHeurList
public void setHeurList(int[] heurArray)Sets the universal set for this dynamic heuristic set.The universal set should contain all heuristics represented in an array of integers where each integer identifies a unique heuristic.
- Parameters:
heurArray- an integer array where each integer uniquely identifies a heuristic
-
setMaxTime
public void setMaxTime(long maxTime)Sets the maximum computational time for this dynamic heuristic set.The maximum time should be the same as the maximum time for the hyper-heuristic using this dynamic heuristic set.
- Parameters:
maxTime- the time limit in millisecond for the hyper-heuristic using this dynamic set
-
init
public void init(double initValue)Initializes this dynamic heuristic set.This method should be called immediately after the hyper-heuristic has created an initial solution and evaluates it.
- Parameters:
initValue- the initial solution value
-
updateActiveList
public java.util.List<java.lang.Integer> updateActiveList()Updates the active set from which the hyper-heuristic is allowed to choose if an update condition is satisfied and returns the currently active set.Note that the returned list contains the indexes of the heuristics in the universal set (not their unique identifiers). The universal set should be passed to this dynamic set using the method
setHeurList.The update condition and the update criterion are implemented in the
updatefield of this dynamic set. This method callsupdateActiveListof theupdatefield to update the active set. Therefore, your logic for updating the active set should go inupdateActiveListof theUpdateclass.- Returns:
- a list containing the integer indexes of the heuristics in the currently active set
- See Also:
Update.updateActiveList()
-
updateHeurValue
public void updateHeurValue(int idx, double currentValue, double newValue, long duration)Updates the performance-related information of the heuristic stored at indexidxin the universal set of this dynamic set.Note that the universal set of this dynamic set is set using
setHeurList. Therefore,heurList.get(idx)returns the heuristic unique identifier.The update includes the percentage and frequency of improvement (disimprovement) achieved (caused) by this heuristic, the total execution time used by this heuristic, the percentage and frequency of improvement over the best solution and the run-best solution, etc.
- Parameters:
idx- the heuristic identifiercurrentValue- the solution value before applying the heuristicnewValue- the solution value after applying the heuristicduration- the time (in millisecond) taken by the heuristic to execute the move
-
restart
public void restart(double initValue)Indicates that a restart strategy is triggered in the hyper-heuristic.This method is relevant to hyper-heuristics that implement a restart strategy. This method is used by this dynamic set to reset run-specific statistics such as the percentage improvement over the run-best solution.
- Parameters:
initValue- the solution value of the solution from which the search is initialized
-
getActiveList
public java.util.List<java.lang.Integer> getActiveList()Returns the currently active set.- Returns:
- a list containing the integer identifiers of the currently active set
-
getRunStatistics
Returns therunStatfield of this dynamic set.- Returns:
- the observer that records the run statistics of heuristics
-
getNumberOfUpdates
public int getNumberOfUpdates()Returns the number of updates performed by this dynamic sets.- Returns:
- the number of updates performed by this dynamic sets
-
getNumberOfRemove
public int getNumberOfRemove()Returns the number of times a removal strategy is triggered.The removal strategy implements the removal condition (when to remove some heuristic permanently) and the removal criterion (which heuristics to remove)
- Returns:
- the number of times a removal strategy is triggered.
- See Also:
Remove
-
getNumberOfResets
public int getNumberOfResets()Returns the number of times the active set is reset to include all heuristics except for permanently removed heuristics.The reset is performed by a reset strategy which decides when to trigger the reset.
- Returns:
- the number of times the active set is reset
-