LotSizingDataModel.Checker 2.0.1
Reusable validation engine for structural, mathematical and objective consistency checks.
Loading...
Searching...
No Matches
SolutionCheckOptions.cs
Go to the documentation of this file.
2
4
5/// <summary>
6/// Configures generic lot-sizing solution checking.
7/// </summary>
8public sealed class SolutionCheckOptions
9{
10 /// <summary>
11 /// Gets or sets the requested checking depth.
12 /// </summary>
14 {
15 get;
16 set;
17 } = SolutionCheckLevel.Full;
18
19 /// <summary>
20 /// Gets or sets the absolute tolerance used for constraint feasibility.
21 /// </summary>
23 {
24 get;
25 set;
26 } = 1.0e-8;
27
28 /// <summary>
29 /// Gets or sets the absolute tolerance used to identify numerical zero.
30 /// </summary>
31 public double ZeroTolerance
32 {
33 get;
34 set;
35 } = 1.0e-9;
36
37 /// <summary>
38 /// Gets or sets the tolerance used for integer and binary values.
39 /// </summary>
41 {
42 get;
43 set;
44 } = 1.0e-7;
45
46 /// <summary>
47 /// Gets or sets the absolute tolerance used when comparing objective values.
48 /// </summary>
50 {
51 get;
52 set;
53 } = 1.0e-8;
54
55 /// <summary>
56 /// Gets or sets the relative tolerance used when comparing objective values.
57 /// </summary>
59 {
60 get;
61 set;
62 } = 1.0e-9;
63
64 /// <summary>
65 /// Gets or sets an optional externally reported objective value that
66 /// takes precedence over the value stored in the candidate solution
67 /// evaluation when objective consistency is checked.
68 /// </summary>
69 /// <remarks>
70 /// This is primarily intended for independently checking a
71 /// <c>KnownResult.ReportedObjectiveValue</c> produced by a solver.
72 /// </remarks>
74 {
75 get;
76 set;
77 }
78
79 /// <summary>
80 /// Gets or sets whether disabled mathematical constraints must be ignored.
81 /// </summary>
83 {
84 get;
85 set;
86 } = true;
87
88 /// <summary>
89 /// Gets or sets whether checking should continue after a structural error.
90 /// </summary>
92 {
93 get;
94 set;
95 } = false;
96
97 /// <summary>
98 /// Validates the checker options.
99 /// </summary>
100 /// <exception cref="ArgumentOutOfRangeException">
101 /// Thrown when a tolerance is negative or non-finite.
102 /// </exception>
103 public void EnsureValid()
104 {
105 if (!Enum.IsDefined(
106 typeof(SolutionCheckLevel),
107 Level))
108 {
109 throw new ArgumentOutOfRangeException(
110 nameof(Level),
111 Level,
112 "The requested solution-check level is not defined.");
113 }
114
115 ValidateTolerance(
117 nameof(FeasibilityTolerance));
118
119 ValidateTolerance(
121 nameof(ZeroTolerance));
122
123 ValidateTolerance(
125 nameof(IntegralityTolerance));
126
127 ValidateTolerance(
130
131 ValidateTolerance(
134
135 if (ReportedObjectiveValueOverride.HasValue &&
136 !double.IsFinite(
138 {
139 throw new ArgumentOutOfRangeException(
142 "The reported objective override must be finite when specified.");
143 }
144 }
145
146 private static void ValidateTolerance(
147 double value,
148 string parameterName)
149 {
150 if (!double.IsFinite(value) ||
151 value < 0.0)
152 {
153 throw new ArgumentOutOfRangeException(
154 parameterName,
155 value,
156 "A numerical tolerance must be finite and non-negative.");
157 }
158 }
159}
Configures generic lot-sizing solution checking.
double ObjectiveRelativeTolerance
Gets or sets the relative tolerance used when comparing objective values.
bool IgnoreDisabledConstraints
Gets or sets whether disabled mathematical constraints must be ignored.
double ZeroTolerance
Gets or sets the absolute tolerance used to identify numerical zero.
double FeasibilityTolerance
Gets or sets the absolute tolerance used for constraint feasibility.
bool ContinueAfterStructuralErrors
Gets or sets whether checking should continue after a structural error.
double ObjectiveAbsoluteTolerance
Gets or sets the absolute tolerance used when comparing objective values.
SolutionCheckLevel Level
Gets or sets the requested checking depth.
double IntegralityTolerance
Gets or sets the tolerance used for integer and binary values.
double? ReportedObjectiveValueOverride
Gets or sets an optional externally reported objective value that takes precedence over the value sto...
SolutionCheckLevel
Defines how deeply a lot-sizing solution must be checked.