LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
GlspStartUpVariableFamilyBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.Relationships;
2using LotSizingDataModel.Instance;
4
6
9{
10 public override string FamilyId =>
11 "glspProductionStartUp";
12
13 public override bool IsEnabled(
14 LotSizingInstance instance,
16 {
17 ArgumentNullException.ThrowIfNull(instance);
18 ArgumentNullException.ThrowIfNull(options);
19
20 return instance.SupplyChain.ProductionCharacteristics.Any(
21 characteristic =>
22 characteristic.StartUpCost is not null ||
23 characteristic.StartUpTime is not null);
24 }
25
26 protected override ValueTask BuildFamilyAsync(
27 LotSizingInstance instance,
30 CancellationToken cancellationToken)
31 {
32 var (plantId, workCenter, profile) =
34
35 IReadOnlyList<ProductionRouting> routings =
37 instance,
38 plantId,
39 workCenter.Id);
40
41 var ordered =
42 profile.EnumerateMicroPeriods().ToArray();
43
44 for (int index = 0;
45 index < ordered.Length;
46 index++)
47 {
48 int fixedFrom =
50 profile,
51 index);
52
53 bool reset =
54 index > 0 &&
56 profile,
57 ordered[index - 1],
58 ordered[index]);
59
60 foreach (ProductionRouting routing
61 in routings)
62 {
63 ProductionCharacteristic characteristic =
65 instance,
66 routing,
67 plantId,
68 workCenter.Id);
69
70 if (characteristic.StartUpCost is null &&
71 characteristic.StartUpTime is null)
72 {
73 continue;
74 }
75
77 context,
78 $"glspStartUp_r{routing.Id}_t{ordered[index].MacroPeriod}_s{ordered[index].MicroPeriodIndex}",
80 plantId,
81 workCenter.Id,
82 routing.Id,
83 routing.ItemId,
84 ordered[index],
85 fixedFrom,
86 reset),
87 "GLSP production start-up occurrence.");
88 }
89 }
90
91 return ValueTask.CompletedTask;
92 }
93}
Provides the shared state required while constructing a solver-independent mathematical model.
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 IsResetBoundary(ProductionSchedulingProfile profile, ProductionMicroPeriodReference previous, ProductionMicroPeriodReference current)
static int GetFixedPredecessorItemId(ProductionSchedulingProfile profile, int index)
override string FamilyId
Gets the unique identifier of the variable family.
override ValueTask BuildFamilyAsync(LotSizingInstance instance, MathematicalModelBuildContext context, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
override bool IsEnabled(LotSizingInstance instance, StandardLotSizingFormulationOptions options)
Determines whether this variable family is enabled for the supplied instance and formulation options.
Builds canonical mathematical domain keys for production start-up events.
static string CreateGlspKey(int plantId, int workCenterId, int routingId, int itemId, ProductionMicroPeriodReference microPeriod, int fixedPredecessorItemId, bool resetBoundary)
Configures the standard solver-independent mixed-integer lot-sizing formulation.
Provides common validation and variable-registration helpers for one variable family of the standard ...
static MathematicalVariable AddBinaryVariable(MathematicalModelBuildContext context, string name, string domainKey, string description="")
Creates and registers one binary variable.