Package io.github.nhtc2005.alns.core
Class AlnsStatistics
java.lang.Object
io.github.nhtc2005.alns.core.AlnsStatistics
Stores objective histories, iteration runtimes, and outcome counts from one ALNS search.
Enabled histories and runtimes contain an entry for the initial solution followed by one entry
per completed iteration, so index k corresponds to iteration k; the initial
runtime is zero. Data getters throw IllegalStateException when collection is disabled.
Outcomes are counted independently of reward eligibility, and each operator in a selected pair
receives the pair's outcome. Retaining full histories uses memory proportional to iteration
count.
-
Method Summary
Modifier and TypeMethodDescriptionReturns an unmodifiable snapshot of best objectives, including the initial value.Returns an unmodifiable snapshot of current objectives, including the initial value.longgetDestroyOperatorCount(int operatorIndex, SolutionStatus status) Returns how often a destroy operator participated in the specified outcome.Returns the destroy operator names; positioninames destroy operatori.Returns an unmodifiable snapshot of iteration runtimes in nanoseconds, including a zero entry for the initial solution.longgetRepairOperatorCount(int operatorIndex, SolutionStatus status) Returns how often a repair operator participated in the specified outcome.Returns the repair operator names; positioninames repair operatori.longgetStatusCount(SolutionStatus status) Returns the total number of iterations with the specified outcome.booleanReturns whether statistics collection was enabled.
-
Method Details
-
isEnabled
public boolean isEnabled()Returns whether statistics collection was enabled.- Returns:
- whether statistics collection was enabled
-
getDestroyOperatorNames
Returns the destroy operator names; positioninames destroy operatori.- Returns:
- an unmodifiable list of destroy operator names
- Throws:
IllegalStateException- if statistics collection is disabled
-
getRepairOperatorNames
Returns the repair operator names; positioninames repair operatori.- Returns:
- an unmodifiable list of repair operator names
- Throws:
IllegalStateException- if statistics collection is disabled
-
getCurrentObjectiveValues
Returns an unmodifiable snapshot of current objectives, including the initial value.- Returns:
- an unmodifiable snapshot of current objectives, including the initial value
- Throws:
IllegalStateException- if statistics collection is disabled
-
getBestObjectiveValues
Returns an unmodifiable snapshot of best objectives, including the initial value.- Returns:
- an unmodifiable snapshot of best objectives, including the initial value
- Throws:
IllegalStateException- if statistics collection is disabled
-
getIterationRuntimesNanos
Returns an unmodifiable snapshot of iteration runtimes in nanoseconds, including a zero entry for the initial solution.Timing includes selection, operators, local search, acceptance, tracking, and selector feedback, but excludes stopping checks, statistics collection, and iteration callbacks.
- Returns:
- an unmodifiable snapshot of iteration runtimes in nanoseconds
- Throws:
IllegalStateException- if statistics collection is disabled
-
getDestroyOperatorCount
Returns how often a destroy operator participated in the specified outcome.- Parameters:
operatorIndex- the zero-based operator indexstatus- the outcome to count- Returns:
- the number of iterations with that operator and outcome
- Throws:
IllegalStateException- if statistics collection is disabledIndexOutOfBoundsException- if the index is invalidNullPointerException- ifstatusis null
-
getRepairOperatorCount
Returns how often a repair operator participated in the specified outcome.- Parameters:
operatorIndex- the zero-based operator indexstatus- the outcome to count- Returns:
- the number of iterations with that operator and outcome
- Throws:
IllegalStateException- if statistics collection is disabledIndexOutOfBoundsException- if the index is invalidNullPointerException- ifstatusis null
-
getStatusCount
Returns the total number of iterations with the specified outcome.- Parameters:
status- the outcome to count- Returns:
- the outcome count
- Throws:
IllegalStateException- if statistics collection is disabledNullPointerException- ifstatusis null
-