LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
ProductionStartUpVariableFamilyBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.Relationships;
2using LotSizingDataModel.Instance;
5
7
8/// <summary>
9/// Builds standard production start-up event variables.
10/// </summary>
11/// <remarks>
12/// For the standard formulation, a start-up event is the exact 0-to-1
13/// transition of the standard routing setup binary. The pre-horizon setup
14/// state is not represented by the standard formulation, therefore period 1
15/// uses the conventional zero predecessor.
16/// </remarks>
19{
20 public override string FamilyId =>
22
23 public override bool IsEnabled(
24 LotSizingInstance instance,
26 {
27 ArgumentNullException.ThrowIfNull(instance);
28 ArgumentNullException.ThrowIfNull(options);
29
30 return
31 options.IncludeProductionSetups &&
32 instance.SupplyChain.ProductionCharacteristics.Any(
33 characteristic =>
34 characteristic.StartUpCost is not null);
35 }
36
37 protected override ValueTask BuildFamilyAsync(
38 LotSizingInstance instance,
41 CancellationToken cancellationToken)
42 {
43 foreach (ProductionRouting routing
44 in instance.SupplyChain.ProductionRoutings)
45 {
46 bool hasStartUpCost =
47 routing.WorkCenters.Any(
48 reference =>
49 instance.SupplyChain.ProductionCharacteristics.Any(
50 characteristic =>
51 characteristic.ItemId == routing.ItemId &&
52 characteristic.WorkCenter.PlantId == reference.PlantId &&
53 characteristic.WorkCenter.WorkCenterId == reference.WorkCenterId &&
54 characteristic.StartUpCost is not null));
55
56 if (!hasStartUpCost)
57 {
58 continue;
59 }
60
61 for (int period = 1;
62 period <= instance.PlanningHorizon;
63 period++)
64 {
65 cancellationToken.ThrowIfCancellationRequested();
66
68 context,
69 $"productionStartUp_r{routing.Id}_t{period}",
71 routing.Id,
72 period),
73 "Production start-up occurrence, distinct from setup state.");
74 }
75 }
76
77 return ValueTask.CompletedTask;
78 }
79}
Provides the shared state required while constructing a solver-independent mathematical model.
Builds canonical mathematical domain keys for production start-up events.
override bool IsEnabled(LotSizingInstance instance, StandardLotSizingFormulationOptions options)
Determines whether this variable family is enabled for the supplied instance and formulation options.
override ValueTask BuildFamilyAsync(LotSizingInstance instance, MathematicalModelBuildContext context, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
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.
Provides the canonical mathematical domain-key categories used to identify lot-sizing decision famili...