LeveledMetrics#
Metrics of a leveled stage, together with how the leveling run went. It's found in CandidateResult.Leveled and SuggestProposal.Leveled, and only when the call's options set Level. It's null when the scheduled stage is cyclic, because then there's no leveled stage.
Declaration#
namespace Plen;
public sealed class LeveledMetrics : IDeepCloneable<LeveledMetrics>, IEquatable<LeveledMetrics>
{
public required Metrics Metrics { get; set; }
public bool Converged { get; set; }
public uint Rounds { get; set; }
public uint Windows { get; set; }
public LeveledMetrics DeepClone();
public bool Equals(LeveledMetrics? other);
}
Properties#
| Property | Type | Description |
|---|---|---|
Metrics |
Metrics |
Finish, overload, conflicts, cycles and cost of the leveled stage, against the baseline. |
Converged |
bool |
Converged of the leveled schedule. |
Rounds |
uint |
Leveling rounds run. |
Windows |
uint |
Overallocation windows left after leveling, for every reason. |
Metrics#
public required Metrics Metrics { get; set; }
The leveled stage measured against the same baseline as the scheduled stage. Metrics.Cost is the stage's cost, and a candidate's CandidateResult.Cost equals it whenever Leveled is set.
Converged#
public bool Converged { get; set; }
ScheduleResult.Converged of the schedule the leveling run returned.
Rounds#
public uint Rounds { get; set; }
LevelingResult.Rounds of the leveling run.
Windows#
public uint Windows { get; set; }
The number of overallocation windows still left in the leveled schedule, summed over all resources, whatever the reason each one remained. 0 means leveling resolved every overallocation. The windows themselves aren't in the result; see ResourceOverallocation for what a window is.
Methods#
DeepClone#
public LeveledMetrics DeepClone()
Returns a copy that shares no nested object with this one.
Equals#
public bool Equals(LeveledMetrics? other)
public override bool Equals(object? obj)
Value equality: Metrics is equal and Converged, Rounds and Windows match. GetHashCode is consistent with it.
ToString#
public override string ToString()
Returns a readable dump of all properties, for logging.
Example#
Score one candidate with leveling and read its leveled stage:
using Plen;
var monday = Moment.FromYmdHm(2026, 8, 10, 8, 0)
?? throw new InvalidOperationException("invalid date");
var data = new ProjectData
{
Tasks =
[
new TaskData(1) { StartDate = monday, Duration = 2.0 },
new TaskData(2) { StartDate = monday, Duration = 2.0 },
],
Resources = [new ResourceData { Id = "dev1" }],
Assignments = [new AssignmentData { Task = 1, Resource = "dev1", Value = 1.0 }],
};
var project = new Project();
project.Solve(data, new SolveOptions());
var changes = new SchedulingChanges();
changes.Assignments.Add.Add(new AssignmentData { Task = 2, Resource = "dev1", Value = 1.0 });
var result = project.Evaluate(
[new Candidate { Id = "dev1-on-2", Changes = changes }],
new EvaluateOptions { Level = new LevelingOptions() });
var leveled = result.Candidates[0].Leveled;
if (leveled is not null)
{
Console.WriteLine($"cost: {leveled.Metrics.Cost}");
Console.WriteLine($"rounds: {leveled.Rounds}, windows left: {leveled.Windows}");
}
Related#
Metrics- the stage metrics it wrapsCandidateResult- where the leveled stage of a candidate is foundEvaluateOptions-Levelturns the leveled stage onLevelingResult- the result of a committed leveling run- Evaluating alternatives - comparing candidates at the leveled stage