LotSizingDataModel.Instance 2.0.1
Lot-sizing instance representation, descriptors and problem characterization.
Loading...
Searching...
No Matches
ParallelSchedulingTopologyAnalyzer.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.Relationships;
2
4
6{
7 public static IReadOnlyList<ParallelRoutingTopologyDescriptor>
9 IEnumerable<ProductionRouting> routings)
10 {
11 ArgumentNullException.ThrowIfNull(
12 routings);
13
14 ProductionRouting[] normalized =
15 routings.ToArray();
16
17 foreach (ProductionRouting routing
18 in normalized)
19 {
20 ArgumentNullException.ThrowIfNull(
21 routing);
22
23 if (routing.Id <= 0 ||
24 routing.ItemId <= 0 ||
25 routing.PlantId <= 0)
26 {
27 throw new InvalidOperationException(
28 "Parallel scheduling analysis requires positive routing, item and plant identifiers.");
29 }
30
31 if (!routing.HasConsistentWorkCenterReferences)
32 {
33 throw new InvalidOperationException(
34 $"Routing '{routing.Id}' contains a work-center reference from another plant.");
35 }
36 }
37
38 return normalized
39 .GroupBy(
40 routing =>
41 routing.ItemId)
42 .Where(
43 group =>
44 group.Count() > 1)
45 .OrderBy(
46 group =>
47 group.Key)
48 .Select(
49 group =>
50 {
51 ProductionRouting[] itemRoutings =
52 group
53 .OrderBy(
54 routing =>
55 routing.Id)
56 .ToArray();
57
58 bool repeatedPlant =
59 itemRoutings
60 .GroupBy(
61 routing =>
62 routing.PlantId)
63 .Any(
64 plantGroup =>
65 plantGroup.Count() > 1);
66
68 group.Key,
69 itemRoutings
70 .Select(
71 routing =>
72 routing.Id)
73 .ToArray(),
74 itemRoutings
75 .Select(
76 routing =>
77 routing.PlantId)
78 .ToArray(),
79 repeatedPlant);
80 })
81 .ToArray();
82 }
83}
static IReadOnlyList< ParallelRoutingTopologyDescriptor > Analyze(IEnumerable< ProductionRouting > routings)