2using System.Collections.Generic;
3using System.Xml.Serialization;
4using LotSizingDataModel.Solution;
13[XmlType(TypeName =
"mathematicalSolutionMappingResult")]
16 private readonly List<string> _diagnostics =
32 [XmlAttribute(
"isSuccessful")]
43 [XmlAttribute(
"processedValueCount")]
54 [XmlAttribute(
"ignoredValueCount")]
65 [XmlAttribute(
"processedCategoryCount")]
86 [XmlAttribute(
"mappingDurationMilliseconds")]
94 TimeSpan.FromMilliseconds(
101 [XmlElement(
"failureMessage")]
111 [XmlArray(
"diagnostics")]
112 [XmlArrayItem(
"diagnostic")]
120 [XmlElement(
"solution")]
136 if (!
string.IsNullOrWhiteSpace(
155 IEnumerable<string> diagnostics)
157 ArgumentNullException.ThrowIfNull(
186 LotSizingSolution solution,
187 TimeSpan mappingDuration)
189 ArgumentNullException.ThrowIfNull(
218 string failureMessage,
219 TimeSpan mappingDuration)
231 failureMessage?.Trim() ??
235 result.AddDiagnostic(
251 throw new InvalidOperationException(
252 "Mapping duration cannot be negative.");
259 throw new InvalidOperationException(
260 "Mapping counters cannot be negative.");
266 throw new InvalidOperationException(
267 "A successful mapping result must contain a " +
268 "lot-sizing solution.");
272 string.IsNullOrWhiteSpace(
275 throw new InvalidOperationException(
276 "A failed mapping result must contain a failure " +
void EnsureValid()
Validates the mathematical-solution mapping result.
bool IsSuccessful
Gets or sets a value indicating whether mapping succeeded.
int ProcessedCategoryCount
Gets or sets the number of decision categories processed during mapping.
MathematicalSolutionMappingResult()
Initializes an empty mathematical-solution mapping result.
int IgnoredValueCount
Gets or sets the number of mathematical variable values ignored during mapping.
int ProcessedValueCount
Gets or sets the number of mathematical variable values processed during mapping.
LotSizingSolution? Solution
Gets or sets the normalized lot-sizing solution produced by the mapping process.
static MathematicalSolutionMappingResult Failure(string failureMessage, TimeSpan mappingDuration)
Creates a failed mathematical-solution mapping result.
void AddDiagnostics(IEnumerable< string > diagnostics)
Adds several diagnostic messages.
List< string > Diagnostics
Gets the mapping diagnostics.
TimeSpan MappingDuration
Gets or sets the mapping duration.
double MappingDurationMilliseconds
Gets or sets the mapping duration in milliseconds for XML serialization.
string FailureMessage
Gets or sets the mapping failure message.
void AddDiagnostic(string? diagnostic)
Adds a non-empty diagnostic message.
static MathematicalSolutionMappingResult Success(LotSizingSolution solution, TimeSpan mappingDuration)
Creates a successful mathematical-solution mapping result.