ProgramMetricAggregator
Models & Types · AiDotNet.Evolution.Programs.Metrics
Turns a dictionary of evaluator metrics into the single scalar quality an archive ranks on.
For Beginners
Your evaluation code measures several things about a candidate program, but the
search can only rank on one number. This class does that conversion and, just as importantly, tells you what it
did. Construct one with default options and call Aggregate;
read Value for the score, check
HasFiniteValue before reporting it as a completed evaluation, and
read Issues when the score is not what you expected.
How It Works
The default strategy reproduces the reference OpenEvolve rule
(openevolve/utils/metrics_utils.py``get_fitness_score, lines 72-118) exactly: an empty dictionary
scores zero; a metric literally named combined_score is converted and returned outright; otherwise the
numeric metrics that are not archive feature dimensions are averaged; and when excluding the feature dimensions
leaves nothing, every numeric metric is averaged instead. Booleans never count as scores - Python treats
True as 1, so averaging a timeout flag in would give a crashed program a mid-range fitness - and
NaN values are dropped, while infinities are not.
Two things are deliberately different. First, every value the rule discards is returned as a
ProgramMetricIssue instead of vanishing, so an evaluator that reports its accuracy as the string
"0.9" is distinguishable from one whose program genuinely scored zero. Second, text is converted only
when it parses to a finite invariant-culture number, where Python’s float() would also accept the
literals nan and inf; that keeps the outcome identical on every target framework. Beyond the
reference rule, Weighted and
Tchebycheff offer aggregations whose parameters are validated
before a run begins rather than assumed.
Constructors
| Constructor | Summary |
|---|---|
ProgramMetricAggregator(ProgramMetricAggregationOptions options) |
Initializes an aggregator. |
Properties
| Property | Summary |
|---|---|
EvolutionOptimizationDirection PreferredDirection { get; } |
Gets whether larger or smaller aggregated values are better under the configured strategy. |
Methods
| Method | Summary |
|---|---|
ProgramMetricAggregationOptions GetOptions() |
Gets an independent copy of the settings this aggregator was validated with. |
ProgramMetricAggregationResult Aggregate(IReadOnlyDictionary<string, ProgramMetricValue> metrics) |
Collapses an all-numeric metrics dictionary into one scalar quality. |
ProgramMetricAggregationResult Aggregate(IReadOnlyDictionary<string, double> metrics) |
Collapses an all-numeric metrics dictionary into one scalar quality. |
ProgramMetricAggregationResult UpstreamFitnessScore(IReadOnlyDictionary<string, ProgramMetricValue> metrics, IEnumerable<string> featureDimensions) |
Applies the reference OpenEvolve fitness rule with no other configuration. |
Fields
| Field | Summary |
|---|---|
string AggregateMetricName |
The metric name reported on an issue that concerns the aggregation itself rather than one metric. |