Class AstarStats

java.lang.Object
org.ddolib.common.solver.stat.SearchStatistics
org.ddolib.common.solver.stat.AstarStats

public class AstarStats extends SearchStatistics
Class tracking statistics specific to A* variants.
  • 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

      protected AstarStats 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:
      createSpecificInstance in class SearchStatistics
      Returns:
      a new instance of the specific subclass
    • copy

      public AstarStats copy()
      Creates and returns a copy of this statistics instance.
      Overrides:
      copy in class SearchStatistics
      Returns:
      a copy of the current statistics
    • updateIncumbent

      public AstarStats updateIncumbent(double incumbent, double gap)
      Returns a new SearchStatistics instance with an updated incumbent value and gap.
      Overrides:
      updateIncumbent in class SearchStatistics
      Parameters:
      incumbent - the new incumbent value
      gap - the new optimality gap
      Returns:
      a new instance with updated incumbent and gap
    • updateStatus

      public AstarStats updateStatus(SearchStatus status)
      Returns a new SearchStatistics instance with an updated search status.
      Overrides:
      updateStatus in class SearchStatistics
      Parameters:
      status - the new SearchStatus
      Returns:
      a new instance with the updated status
    • incrementNbIter

      public AstarStats incrementNbIter()
      Returns a new SearchStatistics instance with the iteration count incremented by one.
      Overrides:
      incrementNbIter in class SearchStatistics
      Returns:
      a new instance with incremented iterations
    • updateFrontierMaxSize

      public AstarStats updateFrontierMaxSize(int frontierSize)
      Returns a new SearchStatistics instance with an updated maximum frontier size.
      Overrides:
      updateFrontierMaxSize in class SearchStatistics
      Parameters:
      frontierSize - the current frontier size to potentially update the maximum
      Returns:
      a new instance with the updated maximum frontier size
    • updateGap

      public AstarStats updateGap(double gap)
      Returns a new SearchStatistics instance with an updated optimality gap.
      Overrides:
      updateGap in class SearchStatistics
      Parameters:
      gap - the new gap value
      Returns:
      a new instance with the updated gap
    • updateNodeCounts

      public AstarStats 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).
      Overrides:
      updateNodeCounts in class SearchStatistics
      Parameters:
      nbExpanded - the number of expanded nodes
      nbGenerated - the number of generated nodes
      Returns:
      a new instance with the updated node counts
    • addNodeCounts

      public AstarStats addNodeCounts(long nbExpanded, long nbGenerated)
      Returns a new SearchStatistics instance with the given numbers of expanded and generated nodes added to the current ones.
      Overrides:
      addNodeCounts in class SearchStatistics
      Parameters:
      nbExpanded - the number of expanded nodes to add
      nbGenerated - the number of generated nodes to add
      Returns:
      a new instance with the updated node counts
    • updateBestBound

      public AstarStats updateBestBound(double bound)
      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:
      updateBestBound in class SearchStatistics
      Parameters:
      bound - a lower bound on the optimal value
      Returns:
      a new instance with the updated best bound
    • updateTime

      public AstarStats updateTime(long time)
      Returns a new SearchStatistics instance with an updated current time.
      Overrides:
      updateTime in class SearchStatistics
      Parameters:
      time - the current time (in milliseconds)
      Returns:
      a new instance with the updated time
    • incrementNbFastLowerBoundPruning

      public AstarStats incrementNbFastLowerBoundPruning()
      Creates and returns a copy of this statistics instance with one more node pruned by the fast lower bound.
      Overrides:
      incrementNbFastLowerBoundPruning in class SearchStatistics
      Returns:
      a new instance with the incremented number of fast lower bound prunings
    • incrementNbDominancePruning

      public AstarStats incrementNbDominancePruning()
      Creates and returns a copy of this statistics instance with one more node pruned by the dominance.
      Overrides:
      incrementNbDominancePruning in class SearchStatistics
      Returns:
      a new instance with the incremented number of dominance prunings
    • addNbFastLowerBoundPruning

      public AstarStats 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.
      Overrides:
      addNbFastLowerBoundPruning in class SearchStatistics
      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

      public AstarStats addNbDominancePruning(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.
      Overrides:
      addNbDominancePruning in class SearchStatistics
      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

      public AstarStats updateValidChildrenPercent(int nbGeneratedChildren, int nbSelectedChildren)
      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 function
      nbSelectedChildren - the number of relevant children (not pruned by upper bound and not in closed list)
      Returns:
      a new instance with updated validChildrenRatio