4using System.Threading.Tasks;
5using LotSizingDataModel.Core.Querying;
6using LotSizingDataModel.Core.Relationships;
7using LotSizingDataModel.Instance;
25 LotSizingInstance instance,
28 ArgumentNullException.ThrowIfNull(instance);
29 ArgumentNullException.ThrowIfNull(options);
31 return options.IncludeResourceActivation &&
35 entry.WorkCenter.FixedUsageCost is not
null);
40 LotSizingInstance instance,
43 CancellationToken cancellationToken)
45 var queries =
new SupplyChainQueries(instance.SupplyChain);
49 .EnumerateWorkCenters(instance.SupplyChain))
51 if (entry.WorkCenter.FixedUsageCost is
null)
56 for (
int period = 1; period <= instance.PlanningHorizon; period++)
58 cancellationToken.ThrowIfCancellationRequested();
60 var maximum = entry.WorkCenter.GetProductionCapacity(period);
70 foreach (ProductionRouting routing
71 in instance.SupplyChain.ProductionRoutings)
74 routing.WorkCenters.FirstOrDefault(candidate =>
75 candidate.PlantId == entry.PlantId &&
76 candidate.WorkCenterId == entry.WorkCenter.Id);
78 if (reference is
null)
83 ProductionCharacteristic characteristic =
84 queries.GetRequiredProductionCharacteristic(
88 var production = context.GetVariable(
90 var unitLoad = characteristic.UnitCapacityConsumption?[period] ?? 1.0;
91 if (maximum.HasValue && unitLoad > 0)
93 expression.Add(production, unitLoad);
97 var bound = estimator.Estimate(instance, routing, period, options);
99 $
"workCenterActivationQuantity_p{entry.PlantId}_w{entry.WorkCenter.Id}_r{routing.Id}_t{period}",
102 description: $
"Production requires activation. Big-M={bound.Value:G17}. {bound.Source}");
106 if (maximum is not
double limit)
109 expression.Subtract(activation, limit);
112 $
"workCenterActivationLink_p{entry.PlantId}" +
113 $
"_w{entry.WorkCenter.Id}_t{period}",
118 "Work-center production load requires activation.");
122 return ValueTask.CompletedTask;
Provides a fluent builder for linear expressions.
LinearExpression Build(bool clone=true)
Builds and validates the linear expression.
Builds stable business-domain keys for mathematical variables and constraints.
string Build()
Builds the immutable domain-key text.
MathematicalDomainKeyBuilder Add(string name, string value)
Adds a text segment.
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 WorkCenterActivation
Identifies work-center activation decision variables.
Provides the canonical mathematical domain-key segment names used by lot-sizing variables and constra...
const string Plant
Plant identifier segment.
const string WorkCenter
Work-center identifier segment.
const string Period
Period index segment.
MathematicalConstraintSense
Identifies the relational sense of a mathematical constraint.