LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
UlsAlgorithmsHeuristicBridgeResult.cs
Go to the documentation of this file.
1using ULSAlgorithms.Results;
2
4
5/// <summary>
6/// Validated feasible result returned by one pinned
7/// ULSAlgorithms heuristic.
8/// </summary>
10{
12 string solverId,
13 string solverName,
14 string solverVersion,
15 UlsSolveStatus externalStatus,
16 double objectiveValue,
17 double setupCost,
18 double productionCost,
19 double holdingCost,
20 IReadOnlyList<double> productionQuantities,
21 IReadOnlyList<double> endingInventories,
22 IReadOnlyList<bool> setupDecisions,
23 TimeSpan solveDuration)
24 {
25 SolverId =
26 solverId?.Trim() ??
27 string.Empty;
28
30 solverName?.Trim() ??
31 string.Empty;
32
34 solverVersion?.Trim() ??
35 string.Empty;
36
38 externalStatus;
39
41 objectiveValue;
42
43 SetupCost =
44 setupCost;
45
47 productionCost;
48
50 holdingCost;
51
53 productionQuantities.ToArray();
54
56 endingInventories.ToArray();
57
59 setupDecisions.ToArray();
60
62 solveDuration;
63
65 }
66
67 public string SolverId
68 {
69 get;
70 }
71
72 public string SolverName
73 {
74 get;
75 }
76
77 public string SolverVersion
78 {
79 get;
80 }
81
82 public UlsSolveStatus ExternalStatus
83 {
84 get;
85 }
86
87 public double ObjectiveValue
88 {
89 get;
90 }
91
92 public double SetupCost
93 {
94 get;
95 }
96
97 public double ProductionCost
98 {
99 get;
100 }
101
102 public double HoldingCost
103 {
104 get;
105 }
106
107 public double[] ProductionQuantities
108 {
109 get;
110 }
111
112 public double[] EndingInventories
113 {
114 get;
115 }
116
117 public bool[] SetupDecisions
118 {
119 get;
120 }
121
122 public TimeSpan SolveDuration
123 {
124 get;
125 }
126
127 public int Horizon =>
129
130 public void EnsureValid()
131 {
132 if (string.IsNullOrWhiteSpace(
133 SolverId) ||
134 string.IsNullOrWhiteSpace(
135 SolverName) ||
136 string.IsNullOrWhiteSpace(
138 {
139 throw new InvalidOperationException(
140 "Heuristic solver provenance must be complete.");
141 }
142
143 if (ExternalStatus !=
144 UlsSolveStatus.Feasible)
145 {
146 throw new InvalidOperationException(
147 $"A heuristic bridge result must be Feasible, not '{ExternalStatus}'.");
148 }
149
150 foreach (double value in new[]
151 {
153 SetupCost,
156 })
157 {
158 if (double.IsNaN(value) ||
159 double.IsInfinity(value))
160 {
161 throw new InvalidOperationException(
162 "Heuristic objective/cost values must be finite.");
163 }
164 }
165
166 if (Horizon <= 0 ||
167 EndingInventories.Length != Horizon ||
168 SetupDecisions.Length != Horizon)
169 {
170 throw new InvalidOperationException(
171 "Heuristic result vectors must be complete and use one common horizon.");
172 }
173
174 if (SolveDuration < TimeSpan.Zero)
175 {
176 throw new InvalidOperationException(
177 "Heuristic solve duration cannot be negative.");
178 }
179 }
180}
UlsAlgorithmsHeuristicBridgeResult(string solverId, string solverName, string solverVersion, UlsSolveStatus externalStatus, double objectiveValue, double setupCost, double productionCost, double holdingCost, IReadOnlyList< double > productionQuantities, IReadOnlyList< double > endingInventories, IReadOnlyList< bool > setupDecisions, TimeSpan solveDuration)