4using System.Threading.Tasks;
5using LotSizingDataModel.Core.Relationships;
6using LotSizingDataModel.Instance;
43 LotSizingInstance instance,
46 ArgumentNullException.ThrowIfNull(instance);
47 ArgumentNullException.ThrowIfNull(options);
49 return instance.SupplyChain.Demands.Count > 0;
56 LotSizingInstance instance,
59 CancellationToken cancellationToken)
61 foreach (Demand demand
in instance.SupplyChain.Demands)
63 DistributionCenterSourcing[] sourcings =
64 instance.SupplyChain.DistributionCenterSourcings
67 sourcing.DistributionCenterId ==
68 demand.DistributionCenterId &&
69 sourcing.ItemId == demand.ItemId)
72 if (sourcings.Length == 0)
74 throw new InvalidOperationException(
75 $
"Demand for distribution center " +
76 $
"{demand.DistributionCenterId} and item " +
77 $
"{demand.ItemId} has no sourcing relation.");
81 period <= instance.PlanningHorizon;
84 cancellationToken.ThrowIfCancellationRequested();
89 foreach (DistributionCenterSourcing sourcing
97 demand.DistributionCenterId,
102 if (options.IncludeBacklog &&
103 sourcing.BacklogConstraint is not
null)
105 string currentBacklogKey =
109 demand.DistributionCenterId,
114 if (context.VariableRegistry.TryGet(
117 currentBacklog is not
null)
125 string previousBacklogKey =
129 demand.DistributionCenterId,
134 if (context.VariableRegistry.TryGet(
137 previousBacklog is not
null)
145 if (options.IncludeShortage &&
146 sourcing.ShortageConstraint is not
null)
152 demand.DistributionCenterId,
157 if (context.VariableRegistry.TryGet(
160 shortage is not
null)
170 $
"demand_c{demand.DistributionCenterId}" +
171 $
"_i{demand.ItemId}_t{period}",
174 demand.GetQuantity(period),
176 "Demand satisfaction with optional " +
177 "backlog and shortage.");
181 return ValueTask.CompletedTask;
Provides a fluent builder for linear expressions.
Provides the shared state required while constructing a solver-independent mathematical model.
Provides the canonical mathematical domain-key categories used to identify lot-sizing decision famili...
const string Shortage
Identifies shortage or lost-sales decision variables.
const string Backlog
Identifies backlog-level decision variables.
const string Delivery
Identifies delivered-quantity decision variables.
Represents one decision variable in a mathematical optimization model.
MathematicalConstraintSense
Identifies the relational sense of a mathematical constraint.