LotSizingDataModel.Checker 2.0.1
Reusable validation engine for structural, mathematical and objective consistency checks.
Loading...
Searching...
No Matches
SolutionCheckSummaryFactory.cs
Go to the documentation of this file.
3
5
6/// <summary>
7/// Builds compact summaries from complete checker results.
8/// </summary>
9public static class SolutionCheckSummaryFactory
10{
11 /// <summary>
12 /// Creates a compact machine-oriented summary.
13 /// </summary>
14 /// <param name="result">Complete checker result.</param>
15 /// <returns>A compact summary containing no mutable reference to the result.</returns>
18 {
19 ArgumentNullException.ThrowIfNull(result);
20
21 var summary =
23 {
24 Level =
25 result.Level,
26 IsValid =
27 result.IsValid,
28 StructuralStatus =
29 GetStatus(
30 requested: true,
31 completed: result.StructuralCheckCompleted,
32 passed: result.IsStructurallyValid),
33 VariableDomainStatus =
34 GetStatus(
35 requested:
36 result.Level >= SolutionCheckLevel.Feasibility,
37 completed: result.VariableDomainCheckCompleted,
38 passed: result.AreVariableDomainsValid),
39 FeasibilityStatus =
40 GetStatus(
41 requested:
42 result.Level >= SolutionCheckLevel.Feasibility,
43 completed: result.FeasibilityCheckCompleted,
44 passed: result.IsFeasible),
45 ObjectiveStatus =
46 GetStatus(
47 requested:
48 result.Level == SolutionCheckLevel.Full,
49 completed: result.ObjectiveCheckCompleted,
50 passed: result.IsObjectiveConsistent),
51 IssueCount =
52 result.Issues.Count,
53 InformationCount =
54 result.Issues.Count(
55 issue =>
56 issue.Severity ==
57 SolutionCheckSeverity.Information),
58 WarningCount =
59 result.Issues.Count(
60 issue =>
61 issue.Severity ==
62 SolutionCheckSeverity.Warning),
63 ErrorCount =
64 result.Issues.Count(
65 issue =>
66 issue.Severity ==
68 ViolatedConstraintCount =
70 MaximumConstraintViolation =
72 TotalConstraintViolation =
74 ReportedObjectiveValue =
76 RecomputedObjectiveValue =
78 ObjectiveDifference =
80 ObjectiveRelativeDifference =
82 ObjectiveComparisonTolerance =
83 result.ObjectiveComparisonTolerance
84 };
85
86 foreach (SolutionCheckIssueKind kind in
87 Enum.GetValues<SolutionCheckIssueKind>())
88 {
89 int count =
90 result.Issues.Count(
91 issue =>
92 issue.Kind == kind);
93
94 if (count == 0)
95 {
96 continue;
97 }
98
99 summary.IssueCountsByKind.Add(
101 {
102 Kind =
103 kind,
104 Count =
105 count
106 });
107 }
108
109 return summary;
110 }
111
112 private static SolutionCheckStageStatus GetStatus(
113 bool requested,
114 bool completed,
115 bool passed)
116 {
117 if (!requested)
118 {
119 return SolutionCheckStageStatus.NotRequested;
120 }
121
122 if (!completed)
123 {
124 return SolutionCheckStageStatus.NotCompleted;
125 }
126
127 return passed
130 }
131}
Associates an issue category with its occurrence count.
Builds compact summaries from complete checker results.
static SolutionCheckSummary Create(SolutionCheckResult result)
Creates a compact machine-oriented summary.
Provides a compact machine-oriented summary of one solution check.
Contains the complete result of checking one lot-sizing solution.
IReadOnlyList< SolutionCheckIssue > Issues
Gets all checker diagnostics.
bool FeasibilityCheckCompleted
Gets or sets whether mathematical feasibility checking completed.
double? ObjectiveRelativeDifference
Gets or sets the relative objective-value difference, scaled by max(1, abs(reported),...
bool AreVariableDomainsValid
Gets or sets whether all checked variable-domain conditions are satisfied.
double TotalConstraintViolation
Gets or sets the sum of mathematical-constraint violations.
SolutionCheckLevel Level
Gets or sets the checking level that was executed.
bool IsFeasible
Gets or sets whether all checked mathematical constraints are feasible.
double MaximumConstraintViolation
Gets or sets the maximum mathematical-constraint violation.
double? ReportedObjectiveValue
Gets or sets the objective value reported by the candidate solution.
double? ObjectiveDifference
Gets or sets the absolute objective-value difference.
int ViolatedConstraintCount
Gets or sets the number of violated mathematical constraints.
bool VariableDomainCheckCompleted
Gets or sets whether variable-domain checking completed.
bool IsStructurallyValid
Gets or sets whether structural validation succeeded.
bool IsObjectiveConsistent
Gets or sets whether objective-value verification succeeded.
bool StructuralCheckCompleted
Gets or sets whether structural checking completed.
bool IsValid
Gets whether the solution passed every check requested by Level.
bool ObjectiveCheckCompleted
Gets or sets whether objective checking completed.
double? RecomputedObjectiveValue
Gets or sets the objective value independently recomputed by the checker.
SolutionCheckLevel
Defines how deeply a lot-sizing solution must be checked.
SolutionCheckStageStatus
Describes the execution and outcome of one logical checker stage.
@ Passed
The stage completed and its checked conditions were satisfied.
SolutionCheckSeverity
Defines the severity of a solution-check issue.
SolutionCheckIssueKind
Identifies the category of an issue detected while checking a solution.