Package org.ddolib.common.solver.stat
Class AstarStats
java.lang.Object
org.ddolib.common.solver.stat.SearchStatistics
org.ddolib.common.solver.stat.AstarStats
Class tracking statistics specific to A* variants.
-
Field Summary
Fields inherited from class org.ddolib.common.solver.stat.SearchStatistics
_bestBound, _currentTime, _frontierMaxSize, _gap, _incumbent, _lastIterationOfGapImprovement, _lastIterationOfImprovement, _lastTimeOfImprovement, _nbDominancePruning, _nbExpandedNodes, _nbFastLowerBoundPruning, _nbGeneratedNodes, _nbIterations, _prevIncumbent, _relativeImprovement, _startTime, _status -
Constructor Summary
ConstructorsConstructorDescriptionAstarStats(long startTime, double initValue) Constructs a new SearchStatistics instance. -
Method Summary
Modifier and TypeMethodDescriptionaddNbDominancePruning(int nbPruning) Creates and returns a copy of this statistics instance with additional nodes pruned by the dominance, for instance those pruned during the compilation of a decision diagram.addNbFastLowerBoundPruning(int nbPruning) Creates and returns a copy of this statistics instance with additional nodes pruned by the fast lower bound, for instance those pruned during the compilation of a decision diagram.addNodeCounts(long nbExpanded, long nbGenerated) Returns a new SearchStatistics instance with the given numbers of expanded and generated nodes added to the current ones.copy()Creates and returns a copy of this statistics instance.protected AstarStatsCreates a new instance of the specific subclass with initial values.Creates and returns a copy of this statistics instance with one more node pruned by the dominance.Creates and returns a copy of this statistics instance with one more node pruned by the fast lower bound.Returns a new SearchStatistics instance with the iteration count incremented by one.updateBestBound(double bound) Returns a new SearchStatistics instance with an updated best bound.updateFrontierMaxSize(int frontierSize) Returns a new SearchStatistics instance with an updated maximum frontier size.updateGap(double gap) Returns a new SearchStatistics instance with an updated optimality gap.updateIncumbent(double incumbent, double gap) Returns a new SearchStatistics instance with an updated incumbent value and gap.updateNodeCounts(long nbExpanded, long nbGenerated) Returns a new SearchStatistics instance with the given numbers of expanded and generated nodes (totals since the beginning of the search).updateStatus(SearchStatus status) Returns a new SearchStatistics instance with an updated search status.updateTime(long time) Returns a new SearchStatistics instance with an updated current time.updateValidChildrenPercent(int nbGeneratedChildren, int nbSelectedChildren) Calculates the local novelty ratio for the current iteration and updates the Exponential Moving Average (EMA).doubleRetrieves the current Exponential Moving Average (EMA) of the novelty percentage.Methods inherited from class org.ddolib.common.solver.stat.SearchStatistics
bestBound, currentTime, frontierMaxSize, gap, incumbent, lastIterationOfGapImprovement, lastIterationOfImprovement, lastTimeOfImprovement, nbDominancePruning, nbExpandedNodes, nbFastLowerBoundPruning, nbGeneratedNodes, nbIterations, prevIncumbent, relativeImprovement, runtime, status, toString
-
Constructor Details
-
AstarStats
public AstarStats(long startTime, double initValue) Constructs a new SearchStatistics instance.- Parameters:
startTime- the start time of the search (in milliseconds)initValue- the initial value for the incumbent
-
-
Method Details
-
createSpecificInstance
Creates a new instance of the specific subclass with initial values. This is used by the copy method to maintain the correct type.- Specified by:
createSpecificInstancein classSearchStatistics- Returns:
- a new instance of the specific subclass
-
copy
Creates and returns a copy of this statistics instance.- Overrides:
copyin classSearchStatistics- Returns:
- a copy of the current statistics
-
updateIncumbent
Returns a new SearchStatistics instance with an updated incumbent value and gap.- Overrides:
updateIncumbentin classSearchStatistics- Parameters:
incumbent- the new incumbent valuegap- the new optimality gap- Returns:
- a new instance with updated incumbent and gap
-
updateStatus
Returns a new SearchStatistics instance with an updated search status.- Overrides:
updateStatusin classSearchStatistics- Parameters:
status- the newSearchStatus- Returns:
- a new instance with the updated status
-
incrementNbIter
Returns a new SearchStatistics instance with the iteration count incremented by one.- Overrides:
incrementNbIterin classSearchStatistics- Returns:
- a new instance with incremented iterations
-
updateFrontierMaxSize
Returns a new SearchStatistics instance with an updated maximum frontier size.- Overrides:
updateFrontierMaxSizein classSearchStatistics- Parameters:
frontierSize- the current frontier size to potentially update the maximum- Returns:
- a new instance with the updated maximum frontier size
-
updateGap
Returns a new SearchStatistics instance with an updated optimality gap.- Overrides:
updateGapin classSearchStatistics- Parameters:
gap- the new gap value- Returns:
- a new instance with the updated gap
-
updateNodeCounts
Returns a new SearchStatistics instance with the given numbers of expanded and generated nodes (totals since the beginning of the search).- Overrides:
updateNodeCountsin classSearchStatistics- Parameters:
nbExpanded- the number of expanded nodesnbGenerated- the number of generated nodes- Returns:
- a new instance with the updated node counts
-
addNodeCounts
Returns a new SearchStatistics instance with the given numbers of expanded and generated nodes added to the current ones.- Overrides:
addNodeCountsin classSearchStatistics- Parameters:
nbExpanded- the number of expanded nodes to addnbGenerated- the number of generated nodes to add- Returns:
- a new instance with the updated node counts
-
updateBestBound
Returns a new SearchStatistics instance with an updated best bound. Any valid lower bound on the optimal value can be given: the best one seen so far is kept.- Overrides:
updateBestBoundin classSearchStatistics- Parameters:
bound- a lower bound on the optimal value- Returns:
- a new instance with the updated best bound
-
updateTime
Returns a new SearchStatistics instance with an updated current time.- Overrides:
updateTimein classSearchStatistics- Parameters:
time- the current time (in milliseconds)- Returns:
- a new instance with the updated time
-
incrementNbFastLowerBoundPruning
Creates and returns a copy of this statistics instance with one more node pruned by the fast lower bound.- Overrides:
incrementNbFastLowerBoundPruningin classSearchStatistics- Returns:
- a new instance with the incremented number of fast lower bound prunings
-
incrementNbDominancePruning
Creates and returns a copy of this statistics instance with one more node pruned by the dominance.- Overrides:
incrementNbDominancePruningin classSearchStatistics- Returns:
- a new instance with the incremented number of dominance prunings
-
addNbFastLowerBoundPruning
Creates and returns a copy of this statistics instance with additional nodes pruned by the fast lower bound, for instance those pruned during the compilation of a decision diagram.- Overrides:
addNbFastLowerBoundPruningin classSearchStatistics- Parameters:
nbPruning- the number of nodes pruned by the fast lower bound to add- Returns:
- a new instance with the updated number of fast lower bound prunings
-
addNbDominancePruning
Creates and returns a copy of this statistics instance with additional nodes pruned by the dominance, for instance those pruned during the compilation of a decision diagram.- Overrides:
addNbDominancePruningin classSearchStatistics- Parameters:
nbPruning- the number of nodes pruned by the dominance to add- Returns:
- a new instance with the updated number of dominance prunings
-
validChildrenPercent
public double validChildrenPercent()Retrieves the current Exponential Moving Average (EMA) of the novelty percentage. A value close to 0.0 indicates that the algorithm is generating a massive amount of redundant or suboptimal states, signaling probable stagnation.- Returns:
- the smoothed ratio value (theoretically between 0 % and 100 %)
-
updateValidChildrenPercent
Calculates the local novelty ratio for the current iteration and updates the Exponential Moving Average (EMA).EMA is a type of moving average that places a greater weight on the most recent data points, providing a smoothed trend of the ratio over time while remaining responsive to recent changes. By smoothing the data, it is less sensitive to extreme local variations—such as nodes with zero or a sudden surge of selected children—resulting in a more stable and reliable indicator of the search efficiency. The smoothing is performed with a default alpha factor of 0.05. If no children were generated, the EMA is not modified to prevent division by zero.
- Parameters:
nbGeneratedChildren- the total number of children generated by the transition functionnbSelectedChildren- the number of relevant children (not pruned by upper bound and not in closed list)- Returns:
- a new instance with updated validChildrenRatio
-