LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
ProductionStartUpCostObjectiveTermBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.Relationships;
2using LotSizingDataModel.Instance;
4
6
7/// <summary>
8/// Adds standard production start-up costs.
9/// </summary>
12{
13 public override string TermFamilyId =>
14 "productionStartUpCost";
15
16 public override bool IsEnabled(
17 LotSizingInstance instance,
19 {
20 ArgumentNullException.ThrowIfNull(instance);
21 ArgumentNullException.ThrowIfNull(options);
22
23 return
24 options.IncludeProductionSetups &&
25 instance.SupplyChain.ProductionCharacteristics.Any(
26 characteristic =>
27 characteristic.StartUpCost is not null);
28 }
29
30 protected override ValueTask BuildTermsAsync(
31 LotSizingInstance instance,
33 LinearExpressionBuilder expressionBuilder,
35 CancellationToken cancellationToken)
36 {
37 foreach (ProductionRouting routing
38 in instance.SupplyChain.ProductionRoutings)
39 {
40 for (int period = 1;
41 period <= instance.PlanningHorizon;
42 period++)
43 {
44 cancellationToken.ThrowIfCancellationRequested();
45
46 double cost =
47 routing.WorkCenters.Sum(
48 reference =>
49 instance.SupplyChain.ProductionCharacteristics
50 .Where(
51 characteristic =>
52 characteristic.ItemId == routing.ItemId &&
53 characteristic.WorkCenter.PlantId == reference.PlantId &&
54 characteristic.WorkCenter.WorkCenterId == reference.WorkCenterId)
55 .Select(
56 characteristic =>
57 characteristic.StartUpCost?[period] ?? 0.0)
58 .SingleOrDefault());
59
60 if (cost == 0.0)
61 {
62 continue;
63 }
64
66 context,
67 expressionBuilder,
69 routing.Id,
70 period),
71 cost);
72 }
73 }
74
75 return ValueTask.CompletedTask;
76 }
77}
Provides a fluent builder for linear expressions.
Provides the shared state required while constructing a solver-independent mathematical model.
override string TermFamilyId
Gets the unique identifier of the objective-term family.
override bool IsEnabled(LotSizingInstance instance, StandardLotSizingFormulationOptions options)
Determines whether this objective-term family is enabled.
override ValueTask BuildTermsAsync(LotSizingInstance instance, MathematicalModelBuildContext context, LinearExpressionBuilder expressionBuilder, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
Builds canonical mathematical domain keys for production start-up events.
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.