LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
GlspStartUpCostObjectiveTermBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.Relationships;
2using LotSizingDataModel.Instance;
4
6
9{
10 public override string TermFamilyId =>
11 "glspProductionStartUpCost";
12
13 public override bool IsEnabled(
14 LotSizingInstance instance,
16 {
17 ArgumentNullException.ThrowIfNull(instance);
18 ArgumentNullException.ThrowIfNull(options);
19
20 return instance.SupplyChain.ProductionCharacteristics.Any(
21 characteristic =>
22 characteristic.StartUpCost is not null);
23 }
24
25 protected override ValueTask BuildTermsAsync(
26 LotSizingInstance instance,
28 LinearExpressionBuilder expressionBuilder,
30 CancellationToken cancellationToken)
31 {
32 var (plantId, workCenter, profile) =
34
35 IReadOnlyList<ProductionRouting> routings =
37 instance,
38 plantId,
39 workCenter.Id);
40
41 var ordered =
42 profile.EnumerateMicroPeriods().ToArray();
43
44 for (int index = 0;
45 index < ordered.Length;
46 index++)
47 {
48 int fixedFrom =
50 profile,
51 index);
52
53 bool reset =
54 index > 0 &&
56 profile,
57 ordered[index - 1],
58 ordered[index]);
59
60 foreach (ProductionRouting routing
61 in routings)
62 {
63 ProductionCharacteristic characteristic =
65 instance,
66 routing,
67 plantId,
68 workCenter.Id);
69
70 double cost =
71 characteristic.StartUpCost?[
72 ordered[index].MacroPeriod] ?? 0.0;
73
74 if (cost == 0.0)
75 {
76 continue;
77 }
78
80 context,
81 expressionBuilder,
83 plantId,
84 workCenter.Id,
85 routing.Id,
86 routing.ItemId,
87 ordered[index],
88 fixedFrom,
89 reset),
90 cost);
91 }
92 }
93
94 return ValueTask.CompletedTask;
95 }
96}
Provides a fluent builder for linear expressions.
Provides the shared state required while constructing a solver-independent mathematical model.
static int WorkCenter ProductionSchedulingProfile Profile GetSchedulingWorkCenter(LotSizingInstance instance)
static ProductionCharacteristic GetCharacteristic(LotSizingInstance instance, ProductionRouting routing, int plantId, int workCenterId)
static IReadOnlyList< ProductionRouting > GetRoutings(LotSizingInstance instance, int plantId, int workCenterId)
static bool IsResetBoundary(ProductionSchedulingProfile profile, ProductionMicroPeriodReference previous, ProductionMicroPeriodReference current)
static int GetFixedPredecessorItemId(ProductionSchedulingProfile profile, int index)
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.
static string CreateGlspKey(int plantId, int workCenterId, int routingId, int itemId, ProductionMicroPeriodReference microPeriod, int fixedPredecessorItemId, bool resetBoundary)
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.