LotSizingDataModel.Instance 2.0.1
Lot-sizing instance representation, descriptors and problem characterization.
Loading...
Searching...
No Matches
SmallBucketSchedulingProblemClassAnalyzer.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.DecisionModel.Scheduling;
3
5
6/// <summary>
7/// Canonical membership analyzer for the DLSP, CSLP and PLSP small-bucket
8/// scheduling families independently of their current solver support state.
9/// </summary>
11{
13 _extensionAnalyzer;
14
20
23 {
24 _extensionAnalyzer =
25 extensionAnalyzer ??
26 throw new ArgumentNullException(
27 nameof(extensionAnalyzer));
28 }
29
33 {
34 ArgumentNullException.ThrowIfNull(descriptor);
35 ArgumentNullException.ThrowIfNull(definition);
36
37 if (
38 definition.Id is not
40 .DiscreteLotSizingAndScheduling and not
42 .ContinuousSetupLotSizing and not
44 .ProportionalLotSizingAndScheduling)
45 {
47 definition,
48 LotSizingProblemClassMatchKind.NotRepresentable,
49 failedRequirements:
50 new[]
51 {
52 "SmallBucketSchedulingAnalyzer:UnsupportedClass"
53 });
54 }
55
56 List<string> incomplete =
57 new();
58
59 List<string> contradictions =
60 new();
61
62 SchedulingDescriptor scheduling =
63 descriptor.Scheduling;
64
65 if (!scheduling.HasIntegratedScheduling)
66 {
67 contradictions.Add(
68 "Scheduling:Integrated");
69 }
70
71 if (!scheduling.HasSmallBucketStructure)
72 {
73 contradictions.Add(
74 "Scheduling:SmallBucket");
75 }
76
77 if (descriptor.Structure.ItemCount == 0)
78 {
79 incomplete.Add(
80 "Structure:ItemCount");
81 }
82 else if (!descriptor.Structure.IsMultiItem)
83 {
84 contradictions.Add(
85 "Structure:MultiItem");
86 }
87
88 if (!descriptor.Structure.IsSingleLevel)
89 {
90 contradictions.Add(
91 "Structure:SingleLevel");
92 }
93
94 if (scheduling.SchedulingResourceCount == 0)
95 {
96 incomplete.Add(
97 "Scheduling:ResourceCount");
98 }
99 else if (!scheduling.HasSingleSchedulingResource)
100 {
101 contradictions.Add(
102 "Scheduling:SingleResource");
103 }
104
105 if (!descriptor.Demand.HasDemand)
106 {
107 contradictions.Add(
108 "Demand:Present");
109 }
110
111 if (!descriptor.Demand.IsDeterministic)
112 {
113 contradictions.Add(
114 "Demand:Deterministic");
115 }
116
117 if (!descriptor.Production.HasProduction)
118 {
119 contradictions.Add(
120 "Production:Present");
121 }
122
123 if (!descriptor.Capacity.HasProductionCapacity)
124 {
125 contradictions.Add(
126 "Capacity:Production");
127 }
128
130 {
131 contradictions.Add(
132 "Capacity:Shared");
133 }
134
135 if (
136 scheduling.SmallBucketProductionMode ==
137 SmallBucketProductionMode.Unspecified)
138 {
139 incomplete.Add(
140 "Scheduling:ProductionMode");
141 }
142
144 {
145 incomplete.Add(
146 "Scheduling:MaximumProducedItemCount");
147 }
148
149 if (contradictions.Count > 0)
150 {
152 definition,
153 LotSizingProblemClassMatchKind.NotApplicable,
154 failedRequirements:
155 contradictions);
156 }
157
158 if (incomplete.Count > 0)
159 {
161 definition,
163 failedRequirements:
164 incomplete);
165 }
166
167 return definition.Id switch
168 {
170 .DiscreteLotSizingAndScheduling =>
171 AssessDlsp(
172 descriptor,
173 definition),
174
176 .ContinuousSetupLotSizing =>
177 AssessCslp(
178 descriptor,
179 definition),
180
182 .ProportionalLotSizingAndScheduling =>
183 AssessPlsp(
184 descriptor,
185 definition),
186
187 _ =>
188 throw new InvalidOperationException(
189 "Unexpected small-bucket scheduling problem class.")
190 };
191 }
192
193 private LotSizingProblemClassMatchResult AssessDlsp(
196 {
197 if (
199 SmallBucketProductionMode.AllOrNothing ||
201 {
202 return NotApplicable(
203 definition,
204 "DLSP:AllOrNothingAndAtMostOneItemPerBucket");
205 }
206
207 return Member(
208 descriptor,
209 definition,
210 coreExtensions:
211 new[]
212 {
214 .IntegratedScheduling,
216 .SmallBucketScheduling,
218 .MaximumProducedItemCount
219 });
220 }
221
222 private LotSizingProblemClassMatchResult AssessCslp(
224 LotSizingProblemClassDefinition definition)
225 {
226 if (
228 SmallBucketProductionMode.Continuous ||
230 {
231 return NotApplicable(
232 definition,
233 "CSLP:ContinuousAndAtMostOneItemPerBucket");
234 }
235
236 return Member(
237 descriptor,
238 definition,
239 coreExtensions:
240 new[]
241 {
243 .IntegratedScheduling,
245 .SmallBucketScheduling,
247 .MaximumProducedItemCount
248 });
249 }
250
251 private LotSizingProblemClassMatchResult AssessPlsp(
252 LotSizingProblemDescriptor descriptor,
253 LotSizingProblemClassDefinition definition)
254 {
255 if (
257 SmallBucketProductionMode.Continuous ||
259 {
260 return NotApplicable(
261 definition,
262 "PLSP:ContinuousAndAtMostTwoItemsPerBucket");
263 }
264
265 if (
267 {
268 return new LotSizingProblemClassMatchResult(
269 definition,
271 failedRequirements:
272 new[]
273 {
274 "PLSP:MaximumSetupTransitionsPerBucket"
275 });
276 }
277
278 if (
280 {
281 return NotApplicable(
282 definition,
283 "PLSP:AtMostOneSetupTransitionPerBucket");
284 }
285
286 return Member(
287 descriptor,
288 definition,
289 coreExtensions:
290 new[]
291 {
293 .IntegratedScheduling,
295 .SmallBucketScheduling,
297 .MaximumSetupCount,
299 .MaximumProducedItemCount
300 });
301 }
302
303 private LotSizingProblemClassMatchResult Member(
304 LotSizingProblemDescriptor descriptor,
305 LotSizingProblemClassDefinition definition,
306 IEnumerable<LotSizingProblemClassExtensionKind>
307 coreExtensions)
308 {
309 var core =
310 new HashSet<LotSizingProblemClassExtensionKind>(
311 coreExtensions);
312
314 _extensionAnalyzer
315 .Analyze(descriptor)
316 .Where(
317 extension =>
318 !core.Contains(extension))
319 .ToArray();
320
321 return new LotSizingProblemClassMatchResult(
322 definition,
323 extensions.Length == 0
325 : LotSizingProblemClassMatchKind.CompatibleExtension,
326 extensions);
327 }
328
329 private static LotSizingProblemClassMatchResult NotApplicable(
330 LotSizingProblemClassDefinition definition,
331 string failedRequirement) =>
332 new(
333 definition,
334 LotSizingProblemClassMatchKind.NotApplicable,
335 failedRequirements:
336 new[]
337 {
338 failedRequirement
339 });
340}
Typed structured description of the factual lot-sizing problem characteristics currently represented ...
Factual integrated lot-sizing/scheduling characteristics.
Identifies modeled extensions outside the six currently executable canonical lot-sizing core signatur...
LotSizingProblemClassMatchResult Assess(LotSizingProblemDescriptor descriptor, LotSizingProblemClassDefinition definition)
LotSizingProblemClassMatchKind
Relationship between an instance descriptor and one canonical problem class.
LotSizingProblemClassExtensionKind
Modeled characteristics outside the canonical core signatures.
CanonicalLotSizingProblemClassId
Stable canonical LotSizingDataModel identifiers for problem classes.