LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
SmallBucketStartUpCostObjectiveTermBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.DecisionModel.Scheduling;
2using LotSizingDataModel.Core.Relationships;
3using LotSizingDataModel.Instance;
5
7
10{
11 public override string TermFamilyId =>
12 "smallBucketProductionStartUpCost";
13
14 public override bool IsEnabled(
15 LotSizingInstance instance,
17 {
18 ArgumentNullException.ThrowIfNull(instance);
19 ArgumentNullException.ThrowIfNull(options);
20
21 return instance.SupplyChain.ProductionCharacteristics.Any(
22 characteristic =>
23 characteristic.StartUpCost is not null);
24 }
25
26 protected override ValueTask BuildTermsAsync(
27 LotSizingInstance instance,
29 LinearExpressionBuilder expressionBuilder,
31 CancellationToken cancellationToken)
32 {
33 ProductionSchedulingProfile profile =
34 instance.SupplyChain.WorkCenters
35 .Single(workCenter => workCenter.SchedulingProfile is not null)
36 .SchedulingProfile!;
37
38 foreach (ProductionRouting routing
39 in instance.SupplyChain.ProductionRoutings)
40 {
41 var reference =
42 routing.WorkCenters.Single();
43
44 ProductionCharacteristic characteristic =
45 instance.SupplyChain.ProductionCharacteristics.Single(
46 candidate =>
47 candidate.ItemId == routing.ItemId &&
48 candidate.WorkCenter.PlantId == reference.PlantId &&
49 candidate.WorkCenter.WorkCenterId == reference.WorkCenterId);
50
51 if (characteristic.StartUpCost is null)
52 {
53 continue;
54 }
55
56 for (int period = 1;
57 period <= instance.PlanningHorizon;
58 period++)
59 {
60 double cost =
61 characteristic.StartUpCost[period];
62
63 if (cost == 0.0)
64 {
65 continue;
66 }
67
69 context,
70 expressionBuilder,
72 profile,
73 routing,
74 period),
75 cost);
76 }
77 }
78
79 return ValueTask.CompletedTask;
80 }
81}
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)
override ValueTask BuildTermsAsync(LotSizingInstance instance, MathematicalModelBuildContext context, LinearExpressionBuilder expressionBuilder, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
override bool IsEnabled(LotSizingInstance instance, StandardLotSizingFormulationOptions options)
Determines whether this objective-term family is enabled.
override string TermFamilyId
Gets the unique identifier of the objective-term family.
Configures the standard solver-independent mixed-integer lot-sizing formulation.
Provides common validation and helper methods for one objective-term family of the standard lot-sizin...
static void AddCostTerm(MathematicalModelBuildContext context, LinearExpressionBuilder expressionBuilder, string domainKey, double coefficient)
Adds one variable cost term to the shared objective.