LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
SmallBucketSingleSetupStateConstraintFamilyBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Instance;
5
7
8/// <summary>
9/// Enforces at most one active routing setup state per small bucket.
10/// </summary>
13{
14 public override string ConstraintFamilyId =>
15 "smallBucketSingleSetupState";
16
17 protected override ValueTask BuildConstraintsAsync(
18 LotSizingInstance instance,
21 CancellationToken cancellationToken)
22 {
23 for (
24 int period = 1;
25 period <= instance.PlanningHorizon;
26 period++)
27 {
28 var expression =
30
31 foreach (
32 var routing
33 in instance.SupplyChain.ProductionRoutings)
34 {
35 string key =
38 .Add(
40 routing.Id)
41 .Add(
43 period)
44 .Build();
45
46 expression.Add(
48 context,
49 key));
50 }
51
53 context,
54 $"smallBucketSingleSetupState_t{period}",
55 expression.Build(),
56 MathematicalConstraintSense.LessThanOrEqual,
57 1.0,
58 description:
59 "At most one routing setup state is active in a small bucket.");
60 }
61
62 return ValueTask.CompletedTask;
63 }
64}
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.
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.