CandidateResult#
The outcome of one Candidate: its metrics at the scheduled stage and, with leveling, at the leveled stage, or the error that rejected it. Project::evaluate and Project::evaluate_with return one per candidate in EvaluateResult::candidates, in input order.
Declaration#
Fields#
| Field | Type | Description |
|---|---|---|
id |
Id |
The candidate's id, echoed. Uniqueness isn't checked. |
error |
Option<RejectedOperation> |
Why the candidate failed: the first rejected operation of its change set, or an input error from its solve or level run. None when the candidate was scored. |
scheduled |
Option<Metrics> |
Metrics after the candidate's changes are applied and solved. Some whenever error is None. |
leveled |
Option<LeveledMetrics> |
Metrics after leveling, plus the leveling summary. Some only when EvaluateOptions::level is set and the scheduled stage has no cycles. |
cost |
Option<f64> |
The cost of the last stage present: leveled, else scheduled. Lower is better. None when error is set. |
error excludes every other optional field: a rejected candidate carries no metrics and no cost. The cost formula is on Metrics.
Field combinations#
| Case | error |
scheduled |
leveled |
cost |
|---|---|---|---|---|
| Rejected | Some |
None |
None |
None |
Scored, no level |
None |
Some |
None |
from scheduled |
Scored with level |
None |
Some |
Some |
from leveled |
Cyclic, with level |
None |
Some (cycles.value > 0) |
None |
from scheduled |
A cyclic candidate isn't rejected: scheduled is measured on the dates the cyclic solve returns.
Serialization#
With the serde feature, CandidateResult implements Serialize and Deserialize. Field names are camelCase, and None fields are left out of the output.
Example#
Score two candidates with leveling. The second one names a resource that doesn't exist, so its result carries only error.
use ;
Output:
to-bob: scheduled cost 0, overload delta -3
to-bob: leveled in 0 rounds
to-bob: cost 0
to-carol: rejected at assignments.update[0]: unknown resource "carol"
For how candidates are run and ranked, see Evaluating alternatives.
Related#
Candidate- the input this result answersEvaluateResult- the container that lists one result per candidateRejectedOperation- the type oferror- Evaluating Alternatives - how rejected and cyclic candidates are reported
- Error handling - candidate errors among failures that don't fail the call