LotSizingDataModel.Instance 2.0.1
Lot-sizing instance representation, descriptors and problem characterization.
Loading...
Searching...
No Matches
Lsi10ScientificProjector.cs
Go to the documentation of this file.
1using System.Globalization;
6
8
9/// <summary>
10/// Projects the stable 1.2.x descriptor / Universal Notation model to LSI/1.0.
11/// </summary>
12public sealed class Lsi10ScientificProjector
13{
16 UniversalLotSizingNotation universalNotation)
17 {
18 ArgumentNullException.ThrowIfNull(descriptor);
19 ArgumentNullException.ThrowIfNull(universalNotation);
20
21 string planning =
22 RenderPlanning(descriptor);
23
24 string alpha =
25 RenderAlpha(descriptor);
26
27 string beta =
28 RenderBeta(universalNotation);
29
30 string gamma =
31 RenderGamma(universalNotation);
32
33 IReadOnlyDictionary<string, string> dimensions =
34 BuildDimensions(descriptor);
35
36 string sigma =
37 string.Join(
38 ",",
39 dimensions.Select(
40 pair => pair.Key + "=" + pair.Value));
41
42 string canonical =
43 "LSI/1.0: pi{" +
44 planning +
45 "} | alpha{" +
46 alpha +
47 "} | beta{" +
48 beta +
49 "} | gamma{" +
50 gamma +
51 "} @ sigma{" +
52 sigma +
53 "}";
54
55 return new Lsi10Projection(
56 canonical,
57 universalNotation.Render(),
58 ProjectLegacyProblemFamily(descriptor),
59 dimensions);
60 }
61
62 private static string RenderPlanning(
64 {
65 string demand =
66 !descriptor.Demand.HasDemand
67 ? "NA"
68 : descriptor.Demand.IsTimeVarying
69 ? "DYN"
70 : "STA";
71
72 string information =
73 !descriptor.Demand.HasDemand
74 ? "NA"
75 : descriptor.Demand.IsDeterministic
76 ? "DET"
77 : "?";
78
79 string bucket =
80 descriptor.Scheduling.BucketMode switch
81 {
82 Core.DecisionModel.Scheduling
83 .SchedulingBucketMode.BigBucket => "BB",
84 Core.DecisionModel.Scheduling
85 .SchedulingBucketMode.SmallBucket => "SB",
86 Core.DecisionModel.Scheduling
87 .SchedulingBucketMode.MacroMicro => "MM",
88 _ => "NA"
89 };
90
91 return string.Join(
92 ";",
93 new[]
94 {
95 "H=F",
96 "TM=DT",
97 "BK=" + bucket,
98 "INF=" + information,
99 "DEM=" + demand,
100 "DEM.SRC=?"
101 });
102 }
103
104 private static string RenderAlpha(
106 {
107 string itemCardinality =
108 descriptor.Structure.ItemCount switch
109 {
110 1 => "1",
111 > 1 => "M",
112 _ => "?"
113 };
114
115 string level =
116 descriptor.Structure
117 .ProductStructureRelationshipCount > 0
118 ? "ML"
119 : "SL";
120
121 string productStructure =
122 descriptor.Structure.ProductStructureType switch
123 {
129 _ => "?"
130 };
131
132 string network =
133 descriptor.SupplyNetwork.ForwardNetwork.Topology switch
134 {
135 SupplyNetworkTopologyType.Independent => "IND",
136 SupplyNetworkTopologyType.Serial => "SER",
137 SupplyNetworkTopologyType.Convergent => "CONV",
138 SupplyNetworkTopologyType.Divergent => "DIV",
139 SupplyNetworkTopologyType.Tree => "TREE",
140 SupplyNetworkTopologyType.General => "GEN",
141 _ => "?"
142 };
143
144 return string.Join(
145 ";",
146 new[]
147 {
148 "I=" + itemCardinality,
149 "L=" + level,
150 "PS=" + productStructure,
151 "NET=" + network,
152 "SITE=" +
153 (descriptor.Structure.IsMultiSite ? "MULTI" : "SINGLE"),
154 "WC=" +
155 descriptor.Structure.WorkCenterCount
156 .ToString(CultureInfo.InvariantCulture)
157 });
158 }
159
160 private static string RenderBeta(
161 UniversalLotSizingNotation notation)
162 {
163 var tokens = new List<string>();
164
165 foreach (UniversalNotationFeature feature
166 in notation.Beta.Features.OrderBy(
167 feature => (int)feature))
168 {
169 string? token =
170 MapFeature(feature);
171
172 if (token is not null)
173 {
174 tokens.Add(token + "=1");
175 }
176 }
177
178 foreach (UniversalTemporalQualifier qualifier
179 in notation.Beta.TemporalQualifiers.OrderBy(
180 qualifier => (int)qualifier.Parameter))
181 {
182 string? parameter =
183 MapTemporalParameter(
184 qualifier.Parameter);
185
186 if (parameter is null)
187 {
188 continue;
189 }
190
191 tokens.Add(
192 "rho(" +
193 parameter +
194 ")=" +
195 MapTemporalPattern(
196 qualifier.Pattern));
197 }
198
199 return tokens.Count == 0
200 ? "NONE"
201 : string.Join(";", tokens);
202 }
203
204 private static string? MapFeature(
206 {
207 return feature switch
208 {
209 UniversalNotationFeature.Demand => "DEM",
210 UniversalNotationFeature.Production => "PROD",
211 UniversalNotationFeature.ProductionCapacity => "CAP.P",
212 UniversalNotationFeature.SharedProductionCapacity => "CAP.P.SH",
213 UniversalNotationFeature.SupplierCapacity => "CAP.S",
214 UniversalNotationFeature.TransportCapacity => "CAP.T",
215 UniversalNotationFeature.WarehouseCapacity => "CAP.W",
216 UniversalNotationFeature.SetupCost => "SET.C",
217 UniversalNotationFeature.SetupTime => "SET.T",
218 UniversalNotationFeature.StartUpCost => "SET.SU.C",
219 UniversalNotationFeature.StartUpTime => "SET.SU.T",
220 UniversalNotationFeature.MinimumLotSize => "LOT.MIN",
221 UniversalNotationFeature.MaximumLotSize => "LOT.MAX",
222 UniversalNotationFeature.LotSizeMultiple => "LOT.MUL",
223 UniversalNotationFeature.ProductionLeadTime => "LT.P",
224 UniversalNotationFeature.InitialInventory => "INV.I0",
225 UniversalNotationFeature.SafetyStock => "INV.SS",
226 UniversalNotationFeature.Backlogging => "SHORT.BO",
227 UniversalNotationFeature.LostSales => "SHORT.LS",
228 UniversalNotationFeature.Purchasing => "SRC.BUY",
229 UniversalNotationFeature.SupplierLeadTime => "LT.S",
230 UniversalNotationFeature.Transportation => "TRANS",
231 UniversalNotationFeature.TransportLeadTime => "LT.T",
232 UniversalNotationFeature.Distribution => "DIST",
233 UniversalNotationFeature.FinancialConstraint => "FIN",
234 UniversalNotationFeature.IntegratedScheduling => "SCH",
235 UniversalNotationFeature.BigBucketScheduling => "SCH.BB",
236 UniversalNotationFeature.SmallBucketScheduling => "SCH.SB",
237 UniversalNotationFeature.MacroMicroScheduling => "SCH.MM",
238 UniversalNotationFeature.InitialSetupState => "SET.INIT",
239 UniversalNotationFeature.SetupCarryOver => "SET.CO",
240 UniversalNotationFeature.SequenceDependentChangeoverTime =>
241 "SET.SD.T",
242 UniversalNotationFeature.SequenceDependentChangeoverCost =>
243 "SET.SD.C",
244 UniversalNotationFeature.MaximumSetupCount => "SCH.MAXSET",
245 UniversalNotationFeature.GroupingConstraint => "LOT.GRP",
246 UniversalNotationFeature.ProductionSetupFamily => "SET.FAM",
247 UniversalNotationFeature.ProductionSetupFamilyTime => "SET.FAM.T",
248 UniversalNotationFeature.AdditionalProductionCapacity =>
249 "CAP.ADD.P",
250 UniversalNotationFeature.AdditionalWarehouseCapacity =>
251 "CAP.ADD.W",
252 UniversalNotationFeature.AdditionalTransportCapacity =>
253 "CAP.ADD.T",
254 _ => null
255 };
256 }
257
258 private static string? MapTemporalParameter(
260 {
261 return parameter switch
262 {
263 UniversalTemporalParameter.Demand => "DEM",
264 UniversalTemporalParameter.SetupCost => "SET.C",
265 UniversalTemporalParameter.HoldingCost => "HOLD.C",
266 UniversalTemporalParameter.ProductionCost => "PROD.C",
267 UniversalTemporalParameter.ProductionCapacity => "CAP.P",
268 UniversalTemporalParameter.MinimumLotSize => "LOT.MIN",
269 UniversalTemporalParameter.StartUpTime => "SET.SU.T",
270 UniversalTemporalParameter.MaximumLotSize => "LOT.MAX",
271 UniversalTemporalParameter.SupplierCapacity => "CAP.S",
272 _ => null
273 };
274 }
275
276 private static string MapTemporalPattern(
277 TemporalPatternType pattern)
278 {
279 return pattern switch
280 {
281 TemporalPatternType.Zero => "Z",
282 TemporalPatternType.Constant => "C",
283 TemporalPatternType.NonIncreasing => "NI",
284 TemporalPatternType.NonDecreasing => "ND",
285 TemporalPatternType.General => "G",
286 _ => "?"
287 };
288 }
289
290 private static string RenderGamma(
291 UniversalLotSizingNotation notation)
292 {
293 string objective =
294 notation.Gamma.Objective switch
295 {
296 UniversalObjectiveKind.Economic => "ECON",
297 UniversalObjectiveKind.MultipleObjectives => "MULTI",
298 UniversalObjectiveKind.Financial => "FIN",
299 UniversalObjectiveKind.Sustainability => "SUST",
300 UniversalObjectiveKind.ServiceLevel => "SERVICE",
301 _ => "?"
302 };
303
304 return "S=MIN;AGG=" +
305 (notation.Gamma.Objective ==
306 UniversalObjectiveKind.MultipleObjectives
307 ? "MULTI"
308 : "SINGLE") +
309 ";OBJ=" +
310 objective;
311 }
312
313 private static IReadOnlyDictionary<string, string>
314 BuildDimensions(
315 LotSizingProblemDescriptor descriptor)
316 {
317 return new Dictionary<string, string>(
318 StringComparer.Ordinal)
319 {
320 ["T"] =
321 descriptor.Time.PlanningHorizon
322 .ToString(CultureInfo.InvariantCulture),
323 ["I"] =
324 descriptor.Structure.ItemCount
325 .ToString(CultureInfo.InvariantCulture),
326 ["P"] =
327 descriptor.Structure.PlantCount
328 .ToString(CultureInfo.InvariantCulture),
329 ["WC"] =
330 descriptor.Structure.WorkCenterCount
331 .ToString(CultureInfo.InvariantCulture),
332 ["WH"] =
333 descriptor.Structure.WarehouseCount
334 .ToString(CultureInfo.InvariantCulture),
335 ["SUP"] =
336 descriptor.Structure.SupplierCount
337 .ToString(CultureInfo.InvariantCulture),
338 ["DC"] =
339 descriptor.Structure.DistributionCenterCount
340 .ToString(CultureInfo.InvariantCulture),
341 ["TR"] =
342 descriptor.Structure.TransportResourceCount
343 .ToString(CultureInfo.InvariantCulture),
344 ["BOM"] =
345 descriptor.Structure.ProductStructureRelationshipCount
346 .ToString(CultureInfo.InvariantCulture),
347 ["DEPTH"] =
348 descriptor.Structure.MaximumProductStructureDepth
349 .ToString(CultureInfo.InvariantCulture)
350 };
351 }
352
353 private static string ProjectLegacyProblemFamily(
354 LotSizingProblemDescriptor descriptor)
355 {
356 bool capacitated =
358
359 bool multiLevel =
360 descriptor.Structure
361 .ProductStructureRelationshipCount > 0;
362
363 if (descriptor.Structure.ItemCount == 1 &&
364 !multiLevel)
365 {
366 return capacitated ? "LS-C" : "LS-U";
367 }
368
369 if (descriptor.Structure.ItemCount > 1 &&
370 !multiLevel)
371 {
372 return capacitated ? "CLSP" : "LS-U";
373 }
374
375 if (descriptor.Structure.ItemCount > 1 &&
376 multiLevel)
377 {
378 return capacitated ? "MLCLSP" : "MLLP";
379 }
380
381 return "?";
382 }
383}
Typed structured description of the factual lot-sizing problem characteristics currently represented ...
Immutable scientific compatibility projection for the LSI/1.0 notation.
Projects the stable 1.2.x descriptor / Universal Notation model to LSI/1.0.
Lsi10Projection Project(LotSizingProblemDescriptor descriptor, UniversalLotSizingNotation universalNotation)
Typed abstract syntax tree for the versioned alpha | beta | gamma scheme.
@ General
The acyclic bill-of-materials graph does not satisfy the serial, assembly or arborescent restrictions...
@ IndependentItems
The instance contains no component-to-parent bill-of-materials relationship.
@ Arborescent
The bill-of-materials graph has an arborescent structure.
@ Serial
Every connected component of the bill-of-materials graph is a directed chain.
@ Assembly
The bill-of-materials graph has an assembly structure.
TemporalPatternType
Canonical temporal-pattern categories used by historical lot-sizing classifications such as Bitran-Ya...
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...
record UniversalTemporalQualifier
Qualifies one universal model-parameter family with a generic temporal pattern.