LotSizingDataModel.Instance 2.0.1
Lot-sizing instance representation, descriptors and problem characterization.
Loading...
Searching...
No Matches
WolseyHistoricalMapper.cs
Go to the documentation of this file.
5
7
8/// <summary>
9/// Projects Wolsey's 2002 classification onto the generic universal notation
10/// without changing the meaning of unsupported historical dimensions.
11/// </summary>
12public sealed class WolseyHistoricalMapper
13{
15 WolseySingleItemClassification classification)
16 {
17 ArgumentNullException.ThrowIfNull(classification);
18
19 return Map(
21 classification));
22 }
23
25 WolseyExtendedClassification classification)
26 {
27 ArgumentNullException.ThrowIfNull(classification);
28
29 var features =
30 new List<UniversalNotationFeature>
31 {
33 UniversalNotationFeature.DeterministicDemand,
34 UniversalNotationFeature.Production,
36 };
37
38 var temporalQualifiers =
39 new List<UniversalTemporalQualifier>();
40
41 var semanticConditions =
42 new List<UniversalSemanticCondition>();
43
44 var missing =
45 new List<string>();
46
47 MapProblemVersion(
48 classification.SingleItem.Problem,
49 semanticConditions,
50 missing);
51
52 MapCapacity(
53 classification.SingleItem.Capacity,
54 features,
55 temporalQualifiers,
56 missing);
57
58 MapVariants(
59 classification.SingleItem.Variants,
60 features,
61 temporalQualifiers,
62 missing);
63
64 MapExtendedDimensions(
65 classification,
66 features,
67 missing);
68
69 UniversalItemCardinality itemCardinality =
70 classification.ItemCount switch
71 {
72 1 => UniversalItemCardinality.Single,
73 > 1 => UniversalItemCardinality.Multiple,
75 };
76
78 classification.MultiLevel is null
80 : UniversalProblemLevel.MultiLevel;
81
83 structure =
84 classification.MultiLevel?.Structure switch
85 {
88 .ProductStructureType.General,
91 .ProductStructureType.Assembly,
94 .ProductStructureType.Serial,
95 _ =>
97 .ProductStructureType.IndependentItems
98 };
99
100 var notation =
102 alpha:
104 {
105 ItemCardinality = itemCardinality,
106 ProblemLevel = level,
107 ProductStructureType = structure,
108 Network =
110 {
111 ForwardTopology =
114 .SupplyNetworkTopologyType.Unknown
115 }
116 },
117 beta:
119 features,
120 temporalQualifiers,
121 semanticConditions),
122 gamma:
124 {
125 Objective =
127 });
128
130 missing.Count == 0
133
134 return new WolseyHistoricalMapping(
135 classification,
137 notation),
138 coverage,
139 missing);
140 }
141
142 private static void MapProblemVersion(
143 WolseyProblemVersion problem,
144 ICollection<UniversalSemanticCondition> semanticConditions,
145 ICollection<string> missing)
146 {
147 switch (problem)
148 {
149 case WolseyProblemVersion.LS:
150 // General LS domain is represented by the common features.
151 break;
152
153 case WolseyProblemVersion.WW:
154 semanticConditions.Add(
157 break;
158
159 case WolseyProblemVersion.DLSI:
160 semanticConditions.Add(
163
164 missing.Add(
165 "PROB.DLSI:VariableInitialStockDecision");
166 break;
167
168 case WolseyProblemVersion.DLS:
169 semanticConditions.Add(
172
173 missing.Add(
174 "PROB.DLS:NoVariableInitialStockDecision");
175 break;
176
177 default:
178 throw new ArgumentOutOfRangeException(
179 nameof(problem),
180 problem,
181 "Unknown Wolsey PROB field.");
182 }
183 }
184
185 private static void MapCapacity(
186 WolseyCapacityRegime capacity,
187 ICollection<UniversalNotationFeature> features,
188 ICollection<UniversalTemporalQualifier> temporalQualifiers,
189 ICollection<string> missing)
190 {
191 switch (capacity)
192 {
194 features.Add(
195 UniversalNotationFeature.ProductionCapacity);
196 features.Add(
199 break;
200
201 case WolseyCapacityRegime.CC:
202 features.Add(
203 UniversalNotationFeature.ProductionCapacity);
204 temporalQualifiers.Add(
208 TemporalPatternType.Constant));
209 break;
210
212 features.Add(
213 UniversalNotationFeature.UncapacitatedProduction);
214 break;
215
216 default:
217 throw new ArgumentOutOfRangeException(
218 nameof(capacity),
219 capacity,
220 "Unknown Wolsey CAP field.");
221 }
222 }
223
224 private static void MapVariants(
225 IEnumerable<WolseyVariant> variants,
226 ICollection<UniversalNotationFeature> features,
227 ICollection<UniversalTemporalQualifier> temporalQualifiers,
228 ICollection<string> missing)
229 {
230 foreach (WolseyVariant variant in variants)
231 {
232 switch (variant)
233 {
234 case WolseyVariant.B:
235 features.Add(
236 UniversalNotationFeature.Backlogging);
237 break;
238
239 case WolseyVariant.SC:
240 // Wolsey SC = start-up cost.
241 features.Add(
242 UniversalNotationFeature.StartUpCost);
243 break;
244
245 case WolseyVariant.ST:
246 features.Add(
247 UniversalNotationFeature.StartUpTime);
248 break;
249
250 case WolseyVariant.STConstant:
251 features.Add(
252 UniversalNotationFeature.StartUpTime);
253 temporalQualifiers.Add(
255 UniversalTemporalParameter.StartUpTime,
256 TemporalPatternType.Constant));
257 break;
258
259 case WolseyVariant.SL:
260 missing.Add(
261 "VAR.SL:AdditionalSales");
262 break;
263
264 case WolseyVariant.LB:
265 features.Add(
266 UniversalNotationFeature.MinimumLotSize);
267 break;
268
269 case WolseyVariant.LBConstant:
270 features.Add(
271 UniversalNotationFeature.MinimumLotSize);
272 temporalQualifiers.Add(
274 UniversalTemporalParameter.MinimumLotSize,
275 TemporalPatternType.Constant));
276 break;
277
278 case WolseyVariant.SS:
279 features.Add(
280 UniversalNotationFeature.SafetyStock);
281 break;
282
283 default:
284 throw new ArgumentOutOfRangeException(
285 nameof(variants),
286 variant,
287 "Unknown Wolsey VAR entry.");
288 }
289 }
290 }
291
292 private static void MapExtendedDimensions(
293 WolseyExtendedClassification classification,
294 ICollection<UniversalNotationFeature> features,
295 ICollection<string> missing)
296 {
297 if (classification.Machines is not null)
298 {
299 WolseyMachineClassification machines =
300 classification.Machines;
301
302 missing.Add(
303 $"Machines.NK={machines.MachineCount}");
304
305 missing.Add(
306 $"Machines.Mode={machines.MachineMode}");
307
308 missing.Add(
309 $"Machines.Bucket={machines.BucketType}");
310
311 if (machines.HasLeadTimes)
312 {
313 features.Add(
314 UniversalNotationFeature.ProductionLeadTime);
315 }
316
317 foreach (
319 in machines.Features)
320 {
321 switch (feature)
322 {
323 case WolseyMachineFeature.SET:
324 features.Add(
325 UniversalNotationFeature.SetupTime);
326 break;
327
328 case WolseyMachineFeature.ST:
329 features.Add(
330 UniversalNotationFeature.StartUpTime);
331 break;
332
333 case WolseyMachineFeature.SQT:
334 features.Add(
337 break;
338
339 case WolseyMachineFeature.SQC:
340 features.Add(
343 break;
344
345 default:
346 throw new ArgumentOutOfRangeException(
347 nameof(classification),
348 feature,
349 "Unknown Wolsey machine feature.");
350 }
351 }
352 }
353
354 if (classification.ItemCount.HasValue)
355 {
356 // NI is represented by alpha item cardinality, but the exact
357 // numerical count is not encoded by universal notation v1.
358 if (classification.ItemCount.Value > 1)
359 {
360 missing.Add(
361 $"NI.ExactCount={classification.ItemCount.Value}");
362 }
363 }
364
365 if (classification.PeriodCount.HasValue)
366 {
367 missing.Add(
368 $"NT.ExactCount={classification.PeriodCount.Value}");
369 }
370
371 if (classification.MultiLevel is not null)
372 {
373 // G/A/S topology is represented. Exact NL count is not.
374 missing.Add(
375 $"NL.ExactCount={classification.MultiLevel.LevelCount}");
376 }
377 }
378}
Preserves Wolsey's optional multi-item/machine/level extension around the single-item PROB-CAP-VAR cl...
Projects Wolsey's 2002 classification onto the generic universal notation without changing the meanin...
WolseyHistoricalMapping Map(WolseySingleItemClassification classification)
WolseyHistoricalMapping Map(WolseyExtendedClassification classification)
Represents a Wolsey historical classification and the portion currently expressible as a universal pr...
Lossless typed representation of Wolsey's PROB-CAP-VAR single-item classification.
Represents a universal notation interpreted as a problem specification.
Typed abstract syntax tree for the versioned alpha | beta | gamma scheme.
Typed alpha-field representation of the physical network.
Alpha field: structural/environment characteristics.
Beta field: constraints and modeled extensions.
ProductStructureType
Identifies the structural category of a product bill-of-materials graph.
TemporalPatternType
Canonical temporal-pattern categories used by historical lot-sizing classifications such as Bitran-Ya...
HistoricalMappingCoverage
Describes how completely a historical classification can currently be represented by the universal no...
@ Exact
Every historical dimension is represented by the universal specification.
WolseyCapacityRegime
Second CAP field of Wolsey's 2002 single-item classification.
WolseyMachineFeature
Capacity-utilization/setup/changeover markers in Wolsey's multi-item extension.
WolseyVariant
Third VAR field extensions of Wolsey's 2002 single-item classification.
WolseyProblemVersion
First PROB field of Wolsey's 2002 single-item classification.
UniversalSemanticCondition
Generic derived semantic conditions that may be required by a universal problem specification.
@ ZeroOrFullCapacityProduction
Whenever production is positive, the modeled lower bound and capacity force production exactly to ful...
@ NonSpeculativeProductionHoldingCosts
Adjacent unit production/acquisition and holding costs satisfy the non-speculative condition.
UniversalTemporalParameter
Identifies a time-varying model parameter that may be qualified by a generic temporal pattern in univ...
UniversalNotationFeature
Feature vocabulary represented in the beta field of notation v1. Enum order is the canonical renderin...
UniversalProblemLevel
Canonical BOM-level token.
record UniversalTemporalQualifier
Qualifies one universal model-parameter family with a generic temporal pattern.
UniversalItemCardinality
Canonical item-cardinality token.