template<Individual I, Fitness F>
class ultra::search_stats< I, F >
Collects statistics across multiple independent search runs.
- Template Parameters
-
| I | individual type |
| F | fitness type |
The class stores per-run summaries ordered by best performance, tracks the distribution of fitness values and records runs that satisfy a user-defined success threshold.
template<Individual I, Fitness F>
Returns a view of the top-performing runs.
- Parameters
-
| [in] | perc | fraction of runs to include in the elite set (0.0 <= perc <= 1.0) |
- Returns
- span referencing the elite run summaries
The returned span contains the best runs according to model_measurements<F> ordering. Runs are sorted from best to worst, therefore the elite set corresponds to a prefix of the internal run summaries.
The number of runs returned is ceil(runs() * perc). If no runs have been recorded or perc is zero, an empty span is returned.
- Note
- The returned span remains valid only as long as the object is not modified.
template<Individual I, Fitness F>
| std::set< std::size_t > search_stats::good_runs |
( |
const model_measurements< F > & | threshold | ) |
const |
|
nodiscard |
Returns the identifiers of runs that satisfy the given threshold.
- Parameters
-
| [in] | threshold | measurements threshold used to identify successful runs |
- Returns
- set of run identifiers
A run is considered successful when its best measurements compare greater-or-equal to threshold (i.e. best_measurements >= threshold).
If threshold is empty (no criteria set), the returned set is empty.
template<Individual I, Fitness F>
| void search_stats::update |
( |
const I & | lr_best_prg, |
|
|
const model_measurements< F > & | lr_measurements, |
|
|
std::chrono::milliseconds | lr_elapsed ) |
Updates statistics with the results of a completed run.
- Parameters
-
| [in] | lr_best_prg | best individual produced by the completed run |
| [in] | lr_measurements | measurements associated with the best individual |
| [in] | lr_elapsed | duration of the completed run |
- Precondition
- lr_measurements.fitness.has_value()
Completed runs are stored in descending lexicographic order of their best measurements:
- higher fitness ranks first;
- when fitness is equal, higher accuracy ranks first;
- for equal fitness, a present accuracy value ranks before std::nullopt.
This ordering is used only to rank completed runs inside stats_; it does not rely on the general ordering semantics of model_measurements<F> (which may, for example, be based on Pareto dominance).