LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
SmallBucketStartUpDefinitionConstraintFamilyBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.DecisionModel.Scheduling;
2using LotSizingDataModel.Core.Relationships;
3using LotSizingDataModel.Instance;
6
8
9/// <summary>
10/// Synchronizes the distinct start-up event with the exact small-bucket
11/// setup-start occurrence.
12/// </summary>
15{
16 public override string ConstraintFamilyId =>
17 "smallBucketProductionStartUpDefinition";
18
19 public override bool IsEnabled(
20 LotSizingInstance instance,
22 {
23 ArgumentNullException.ThrowIfNull(instance);
24 ArgumentNullException.ThrowIfNull(options);
25
26 return instance.SupplyChain.ProductionCharacteristics.Any(
27 characteristic =>
28 characteristic.StartUpCost is not null ||
29 characteristic.StartUpTime is not null);
30 }
31
32 protected override ValueTask BuildConstraintsAsync(
33 LotSizingInstance instance,
36 CancellationToken cancellationToken)
37 {
38 ProductionSchedulingProfile profile =
39 instance.SupplyChain.WorkCenters
40 .Single(workCenter => workCenter.SchedulingProfile is not null)
41 .SchedulingProfile!;
42
43 foreach (ProductionRouting routing
44 in instance.SupplyChain.ProductionRoutings)
45 {
46 var reference =
47 routing.WorkCenters.Single();
48
49 ProductionCharacteristic characteristic =
50 instance.SupplyChain.ProductionCharacteristics.Single(
51 candidate =>
52 candidate.ItemId == routing.ItemId &&
53 candidate.WorkCenter.PlantId == reference.PlantId &&
54 candidate.WorkCenter.WorkCenterId == reference.WorkCenterId);
55
56 if (characteristic.StartUpCost is null &&
57 characteristic.StartUpTime is null)
58 {
59 continue;
60 }
61
62 for (int period = 1;
63 period <= instance.PlanningHorizon;
64 period++)
65 {
66 cancellationToken.ThrowIfCancellationRequested();
67
68 MathematicalVariable startUp =
70 context,
72 profile,
73 routing,
74 period));
75
76 MathematicalVariable setupStart =
78 context,
80 profile,
81 routing,
82 period));
83
85 context,
86 $"smallBucketProductionStartUpDefinition_r{routing.Id}_t{period}",
88 .Add(startUp)
89 .Subtract(setupStart)
90 .Build(),
92 0.0);
93 }
94 }
95
96 return ValueTask.CompletedTask;
97 }
98}
Provides a fluent builder for linear expressions.
Provides the shared state required while constructing a solver-independent mathematical model.
Builds canonical mathematical domain keys for production start-up events.
static string CreateSmallBucketKey(ProductionSchedulingProfile profile, ProductionRouting routing, int period)
static string CreateSetupStartKey(ProductionSchedulingProfile profile, ProductionRouting routing, int period)
Synchronizes the distinct start-up event with the exact small-bucket setup-start occurrence.
override ValueTask BuildConstraintsAsync(LotSizingInstance instance, MathematicalModelBuildContext context, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
override bool IsEnabled(LotSizingInstance instance, StandardLotSizingFormulationOptions options)
Determines whether this constraint family is enabled.
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.
Represents one decision variable in a mathematical optimization model.
MathematicalConstraintSense
Identifies the relational sense of a mathematical constraint.