LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
WarehouseAdditionalCapacityVariableFamilyBuilder.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 warehouse-capacity variables.
13/// </summary>
16{
17 /// <summary>
18 /// Gets the warehouse additional-capacity variable-family
19 /// identifier.
20 /// </summary>
21 public override string FamilyId =>
23
24 /// <summary>
25 /// Determines whether additional warehouse-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.Warehouse.AdditionalCapacity is not null);
46 }
47
48 /// <summary>
49 /// Builds additional warehouse-capacity variables.
50 /// </summary>
51 protected override ValueTask BuildFamilyAsync(
52 LotSizingInstance instance,
55 CancellationToken cancellationToken)
56 {
57 foreach (
58 var entry
60 .EnumerateWarehouses(
61 instance.SupplyChain))
62 {
63 if (entry.Warehouse.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.Warehouse.AdditionalCapacity[period];
77
79 upperBound,
80 options))
81 {
82 continue;
83 }
84
85 var keyBuilder =
88 .WarehouseAdditionalCapacity);
89
91 keyBuilder,
92 entry.Reference);
93
94 string domainKey =
95 keyBuilder
96 .Add(
98 period)
99 .Build();
100
102 context,
103 $"OH_w{entry.Reference.ReferenceId}_t{period}",
104 domainKey,
105 upperBound,
106 $"Additional capacity of warehouse " +
107 $"{entry.Reference.ReferenceId} in period " +
108 $"{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.
Creates canonical domain-key fragments shared by standard formulation builders and provides warehouse...
static MathematicalDomainKeyBuilder AddWarehouse(MathematicalDomainKeyBuilder builder, WarehouseReference warehouse)
Adds a warehouse reference using the generic warehouse or plant segment.
Enumerates physical resources together with the canonical references required by the mathematical for...
static IEnumerable<(WarehouseReference Reference, Warehouse Warehouse)> EnumerateWarehouses(SupplyChain supplyChain)
Enumerates every standalone and plant warehouse.
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 ValueTask BuildFamilyAsync(LotSizingInstance instance, MathematicalModelBuildContext context, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
Builds additional warehouse-capacity variables.
override string FamilyId
Gets the warehouse additional-capacity variable-family identifier.
override bool IsEnabled(LotSizingInstance instance, StandardLotSizingFormulationOptions options)
Determines whether additional warehouse-capacity variables are enabled.
Provides the canonical mathematical domain-key categories used to identify lot-sizing decision famili...
const string WarehouseAdditionalCapacity
Identifies additional warehouse-capacity decision variables.
Provides the canonical mathematical domain-key segment names used by lot-sizing variables and constra...