2using System.Xml.Serialization;
3using LotSizingDataModel.Core.Common;
39[XmlType(TypeName =
"classificationEvidence")]
42 private string _ruleCode =
45 private string _featureCode =
48 private string _description =
51 private string _expectedValue =
54 private string _observedValue =
57 private bool _isSatisfied;
58 private bool _isRequired =
true;
59 private double _weight = 1.0;
61 private string _comment =
104 string expectedValue,
105 string observedValue,
107 bool isRequired =
true,
108 string description =
"")
110 if (
string.IsNullOrWhiteSpace(featureCode))
112 throw new ArgumentException(
113 "A classification feature code is required.",
114 nameof(featureCode));
147 [XmlAttribute(
"ruleCode")]
155 value?.Trim() ??
string.Empty))
177 [XmlAttribute(
"featureCode")]
183 value?.Trim() ??
string.Empty);
195 [XmlElement(
"description")]
201 value?.Trim() ??
string.Empty);
214 [XmlElement(
"expectedValue")]
217 get => _expectedValue;
220 value?.Trim() ??
string.Empty);
227 [XmlElement(
"observedValue")]
230 get => _observedValue;
233 value?.Trim() ??
string.Empty);
240 [XmlAttribute(
"satisfied")]
250 NotifyDerivedProperties();
267 [XmlAttribute(
"required")]
277 NotifyDerivedProperties();
297 [XmlAttribute(
"weight")]
303 if (!
double.IsFinite(value) ||
306 throw new ArgumentOutOfRangeException(
309 "The evidence weight must be finite " +
310 "and non-negative.");
328 [XmlElement(
"comment")]
336 value?.Trim() ??
string.Empty))
350 !
string.IsNullOrWhiteSpace(
359 !
string.IsNullOrWhiteSpace(
410 $
"{FeatureCode}: expected " +
411 $
"'{ExpectedValue}', observed " +
412 $
"'{ObservedValue}' — {result}, " +
416 private void NotifyDerivedProperties()
bool IsRequired
Gets or sets a value indicating whether the evaluated condition is mandatory for a direct match.
bool IsSatisfied
Gets or sets a value indicating whether the observed feature satisfies the expected condition.
double Weight
Gets or sets the relative importance assigned to this evidence during approximate matching.
string Comment
Gets or sets an optional explanatory comment about the evidence.
string RuleCode
Gets or sets an optional stable identifier for the classification rule that produced this evidence.
bool IsBlockingMismatch
Gets a value indicating whether a required condition is not satisfied.
bool HasRuleCode
Gets a value indicating whether a classification-rule code has been recorded.
ClassificationEvidence(string featureCode, string expectedValue, string observedValue, bool isSatisfied, bool isRequired=true, string description="")
Initializes a classification-evidence object.
bool HasComment
Gets a value indicating whether an explanatory comment has been recorded.
string ExpectedValue
Gets or sets the value expected by the known problem-family rule.
string FeatureCode
Gets or sets the stable code of the feature that was evaluated.
string ObservedValue
Gets or sets the value observed in the analyzed lot-sizing instance.
bool IsOptionalMismatch
Gets a value indicating whether an optional condition is not satisfied.
ClassificationEvidence()
Initializes an empty classification-evidence object.
bool SupportsMatch
Gets a value indicating whether this evidence supports the evaluated problem-family match.
override string ToString()
string Description
Gets or sets a human-readable description of the evaluated condition.