LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
SmallBucketProducedItemCountConstraintFamilyBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.DecisionModel.Scheduling;
2using LotSizingDataModel.Instance;
6
8
9/// <summary>
10/// Enforces the real period-dependent MaximumProducedItemCount parameter from
11/// positive-production activation variables.
12/// </summary>
15{
16 public override string ConstraintFamilyId =>
17 "smallBucketProducedItemCount";
18
19 protected override ValueTask BuildConstraintsAsync(
20 LotSizingInstance instance,
23 CancellationToken cancellationToken)
24 {
25 ProductionSchedulingProfile profile =
26 instance.SupplyChain.WorkCenters
27 .Single(
28 workCenter =>
29 workCenter.SchedulingProfile is not null)
30 .SchedulingProfile!;
31
32 MaximumProducedItemCount limit =
33 profile.MaximumProducedItemCount ??
34 throw new InvalidOperationException(
35 "Executable small-bucket formulations require MaximumProducedItemCount.");
36
37 for (
38 int period = 1;
39 period <= instance.PlanningHorizon;
40 period++)
41 {
42 var expression =
44
45 foreach (
46 var routing
47 in instance.SupplyChain.ProductionRoutings)
48 {
49 string key =
52 .AuxiliarySmallBucketProductionActivation)
53 .Add(
55 routing.Id)
56 .Add(
58 period)
59 .Build();
60
61 expression.Add(
63 context,
64 key));
65 }
66
68 context,
69 $"smallBucketProducedItemCount_t{period}",
70 expression.Build(),
71 MathematicalConstraintSense.LessThanOrEqual,
72 limit.GetCount(period),
73 description:
74 "Maximum number of distinct positively produced items in the bucket.");
75 }
76
77 return ValueTask.CompletedTask;
78 }
79}
Provides a fluent builder for linear expressions.
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.
MathematicalModel Build(bool clone=true)
Builds and validates the mathematical model.
Enforces the real period-dependent MaximumProducedItemCount parameter from positive-production activa...
override ValueTask BuildConstraintsAsync(LotSizingInstance instance, MathematicalModelBuildContext context, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
Provides common validation and helper methods for one constraint family of the standard lot-sizing fo...
static MathematicalVariable GetVariable(MathematicalModelBuildContext context, string domainKey)
Resolves a required variable from its canonical domain key.
static void AddConstraint(MathematicalModelBuildContext context, string name, LinearExpression expression, MathematicalConstraintSense sense, double rightHandSide, string domainKey="", string description="")
Adds one linear constraint to the mathematical model.
Configures the standard solver-independent mixed-integer lot-sizing formulation.
Provides the canonical mathematical domain-key categories used to identify lot-sizing decision famili...
Provides the canonical mathematical domain-key segment names used by lot-sizing variables and constra...
MathematicalConstraintSense
Identifies the relational sense of a mathematical constraint.