LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
WorkCenterAdditionalCapacityVariableFamilyBuilder.cs
Go to the documentation of this file.
1using System;
2using System.Linq;
3using System.Threading;
4using System.Threading.Tasks;
5using LotSizingDataModel.Instance;
8
10
11/// <summary>
12/// Builds global additional work-center capacity variables.
13/// </summary>
16{
17 /// <summary>
18 /// Gets the work-center additional-capacity variable-family
19 /// identifier.
20 /// </summary>
21 public override string FamilyId =>
23
24 /// <summary>
25 /// Determines whether additional work-center capacity
26 /// variables are enabled.
27 /// </summary>
28 public override bool IsEnabled(
29 LotSizingInstance instance,
31 {
32 ArgumentNullException.ThrowIfNull(
33 instance);
34
35 ArgumentNullException.ThrowIfNull(
36 options);
37
38 return
39 options.IncludeAdditionalCapacity &&
42 instance.SupplyChain)
43 .Any(
44 entry =>
45 entry.WorkCenter.AdditionalCapacity is not null);
46 }
47
48 /// <summary>
49 /// Builds additional work-center capacity variables.
50 /// </summary>
51 protected override ValueTask BuildFamilyAsync(
52 LotSizingInstance instance,
55 CancellationToken cancellationToken)
56 {
57 foreach (
58 var entry
60 .EnumerateWorkCenters(
61 instance.SupplyChain))
62 {
63 if (entry.WorkCenter.AdditionalCapacity is null)
64 {
65 continue;
66 }
67
68 for (
69 int period = 1;
70 period <= instance.PlanningHorizon;
71 period++)
72 {
73 cancellationToken.ThrowIfCancellationRequested();
74
75 double upperBound =
76 entry.WorkCenter.AdditionalCapacity[period];
77
79 upperBound,
80 options))
81 {
82 continue;
83 }
84
85 string domainKey =
88 .WorkCenterAdditionalCapacity)
89 .Add(
91 entry.PlantId)
92 .Add(
94 entry.WorkCenter.Id)
95 .Add(
97 period)
98 .Build();
99
101 context,
102 $"OW_p{entry.PlantId}_w" +
103 $"{entry.WorkCenter.Id}_t{period}",
104 domainKey,
105 upperBound,
106 $"Additional capacity of work center " +
107 $"{entry.WorkCenter.Id} in plant " +
108 $"{entry.PlantId}, period {period}.");
109 }
110 }
111
112 return ValueTask.CompletedTask;
113 }
114}
Builds stable business-domain keys for mathematical variables and constraints.
MathematicalDomainKeyBuilder Add(string name, string value)
Adds a text segment.
Provides the shared state required while constructing a solver-independent mathematical model.
Enumerates physical resources together with the canonical references required by the mathematical for...
static IEnumerable<(int PlantId, WorkCenter WorkCenter)> EnumerateWorkCenters(SupplyChain supplyChain)
Enumerates every work center with its containing plant identifier.
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 bool IsStructurallyZero(double upperBound, StandardLotSizingFormulationOptions options)
Determines whether a finite non-negative upper bound is structurally equal to zero according to the f...
static MathematicalVariable AddNonNegativeContinuousVariable(MathematicalModelBuildContext context, string name, string domainKey, double upperBound=double.PositiveInfinity, string description="")
Creates and registers one continuous non-negative variable.
override bool IsEnabled(LotSizingInstance instance, StandardLotSizingFormulationOptions options)
Determines whether additional work-center capacity variables are enabled.
override ValueTask BuildFamilyAsync(LotSizingInstance instance, MathematicalModelBuildContext context, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
Builds additional work-center capacity variables.
override string FamilyId
Gets the work-center additional-capacity variable-family identifier.
Provides the canonical mathematical domain-key categories used to identify lot-sizing decision famili...
const string WorkCenterAdditionalCapacity
Identifies additional work-center-capacity decision variables.
Provides the canonical mathematical domain-key segment names used by lot-sizing variables and constra...