LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
GlspSchedulingData.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.DecisionModel.Scheduling;
2using LotSizingDataModel.Core.PhysicalModel;
3using LotSizingDataModel.Core.Relationships;
4using LotSizingDataModel.Instance;
5
7
8internal static class GlspSchedulingData
9{
10 public static bool TryGetSchedulingWorkCenter(
11 LotSizingInstance instance,
12 out int plantId,
13 out WorkCenter? workCenter,
14 out ProductionSchedulingProfile? profile)
15 {
16 ArgumentNullException.ThrowIfNull(instance);
17
18 var entries =
19 instance.SupplyChain.Plants
20 .SelectMany(
21 plant =>
22 plant.WorkCenters.Select(
23 candidate =>
24 (
25 PlantId: plant.Id,
26 WorkCenter: candidate
27 )))
28 .Where(
29 entry =>
30 entry.WorkCenter.SchedulingProfile is not null)
31 .Take(2)
32 .ToArray();
33
34 if (entries.Length != 1)
35 {
36 plantId = 0;
37 workCenter = null;
38 profile = null;
39
40 return false;
41 }
42
43 plantId =
44 entries[0].PlantId;
45
46 workCenter =
47 entries[0].WorkCenter;
48
49 profile =
50 entries[0].WorkCenter.SchedulingProfile;
51
52 return
53 profile is not null;
54 }
55
56 public static (
59 ProductionSchedulingProfile Profile)
61 LotSizingInstance instance)
62 {
64 instance,
65 out int plantId,
66 out WorkCenter? workCenter,
67 out ProductionSchedulingProfile? profile) ||
68 workCenter is null ||
69 profile is null)
70 {
71 throw new InvalidOperationException(
72 "Executable GLSP requires exactly one scheduling work center.");
73 }
74
75 return (
76 plantId,
77 workCenter,
78 profile);
79 }
80
81 public static IReadOnlyList<ProductionRouting> GetRoutings(
82 LotSizingInstance instance,
83 int plantId,
84 int workCenterId)
85 {
86 ArgumentNullException.ThrowIfNull(instance);
87
88 return instance.SupplyChain.ProductionRoutings
89 .Where(
90 routing =>
91 routing.WorkCenters.Any(
92 reference =>
93 reference.PlantId == plantId &&
94 reference.WorkCenterId ==
95 workCenterId))
96 .OrderBy(
97 routing =>
98 routing.Id)
99 .ToArray();
100 }
101
102 public static bool TryGetCharacteristic(
103 LotSizingInstance instance,
104 ProductionRouting routing,
105 int plantId,
106 int workCenterId,
107 out ProductionCharacteristic? characteristic)
108 {
109 ArgumentNullException.ThrowIfNull(instance);
110 ArgumentNullException.ThrowIfNull(routing);
111
112 ProductionCharacteristic[] matches =
113 instance.SupplyChain.ProductionCharacteristics
114 .Where(
115 candidate =>
116 candidate.ItemId ==
117 routing.ItemId &&
118 candidate.WorkCenter.PlantId ==
119 plantId &&
120 candidate.WorkCenter.WorkCenterId ==
121 workCenterId)
122 .Take(2)
123 .ToArray();
124
125 if (matches.Length != 1)
126 {
127 characteristic = null;
128
129 return false;
130 }
131
132 characteristic =
133 matches[0];
134
135 return true;
136 }
137
138 public static ProductionCharacteristic GetCharacteristic(
139 LotSizingInstance instance,
140 ProductionRouting routing,
141 int plantId,
142 int workCenterId)
143 {
145 instance,
146 routing,
147 plantId,
148 workCenterId,
149 out ProductionCharacteristic? characteristic) ||
150 characteristic is null)
151 {
152 throw new InvalidOperationException(
153 $"Executable GLSP requires exactly one production " +
154 $"characteristic for routing {routing.Id} on " +
155 $"Plant:{plantId}/WorkCenter:{workCenterId}.");
156 }
157
158 return characteristic;
159 }
160
161 public static ProductionChangeover? FindChangeover(
162 ProductionSchedulingProfile profile,
163 int fromItemId,
164 int toItemId)
165 {
166 ArgumentNullException.ThrowIfNull(profile);
167
168 return profile.Changeovers
169 .SingleOrDefault(
170 changeover =>
171 changeover.FromItemId ==
172 fromItemId &&
173 changeover.ToItemId ==
174 toItemId);
175 }
176}
static ? ProductionChangeover FindChangeover(ProductionSchedulingProfile profile, int fromItemId, int toItemId)
static bool TryGetCharacteristic(LotSizingInstance instance, ProductionRouting routing, int plantId, int workCenterId, out ProductionCharacteristic? characteristic)
static int WorkCenter ProductionSchedulingProfile Profile GetSchedulingWorkCenter(LotSizingInstance instance)
static ProductionCharacteristic GetCharacteristic(LotSizingInstance instance, ProductionRouting routing, int plantId, int workCenterId)
static IReadOnlyList< ProductionRouting > GetRoutings(LotSizingInstance instance, int plantId, int workCenterId)
static bool TryGetSchedulingWorkCenter(LotSizingInstance instance, out int plantId, out WorkCenter? workCenter, out ProductionSchedulingProfile? profile)