LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
PlspSetupTransitionLimitConstraintFamilyBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.DecisionModel.Scheduling;
2using LotSizingDataModel.Instance;
6
8
9/// <summary>
10/// Enforces period-specific zero-transition PLSP buckets. A limit of one is
11/// already intrinsic to the incoming/outgoing state representation.
12/// </summary>
15{
16 public override string ConstraintFamilyId =>
17 "plspSetupTransitionLimit";
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 MaximumSetupCount limit =
33 profile.MaximumSetupCount ??
34 throw new InvalidOperationException(
35 "Executable PLSP requires MaximumSetupCount.");
36
37 for (
38 int period = 2;
39 period <= instance.PlanningHorizon;
40 period++)
41 {
42 if (limit.GetCount(period) != 0)
43 {
44 continue;
45 }
46
47 foreach (
48 var routing
49 in instance.SupplyChain.ProductionRoutings)
50 {
52 context,
53 $"plspNoSetupTransition_r{routing.Id}_t{period}",
55 .Add(
57 context,
58 SetupKey(
59 routing.Id,
60 period)))
61 .Subtract(
63 context,
64 SetupKey(
65 routing.Id,
66 period - 1)))
67 .Build(),
69 0.0,
70 description:
71 "A zero transition limit preserves the incoming PLSP setup state.");
72 }
73 }
74
75 return ValueTask.CompletedTask;
76 }
77
78 private static string SetupKey(
79 int routingId,
80 int period) =>
83 .Add(
85 routingId)
86 .Add(
88 period)
89 .Build();
90}
Provides a fluent builder for linear expressions.
LinearExpressionBuilder Subtract(MathematicalVariable variable, double coefficient=1.0)
Subtracts a variable term from the expression.
LinearExpression Build(bool clone=true)
Builds and validates the linear expression.
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.
Enforces period-specific zero-transition PLSP buckets. A limit of one is already intrinsic to the inc...
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...
const string Setup
Identifies production setup decision variables.
Provides the canonical mathematical domain-key segment names used by lot-sizing variables and constra...
MathematicalConstraintSense
Identifies the relational sense of a mathematical constraint.