LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
InventorySetupCostObjectiveTermBuilder.cs
Go to the documentation of this file.
1using System;
2using System.Threading;
3using System.Threading.Tasks;
4using LotSizingDataModel.Core.Relationships;
5using LotSizingDataModel.Instance;
8
10
11/// <summary>
12/// Adds item-specific inventory setup costs to the standard
13/// objective.
14/// </summary>
17{
18 /// <summary>
19 /// Gets the objective-term family identifier.
20 /// </summary>
21 public override string TermFamilyId =>
22 "inventorySetupCost";
23
24 /// <summary>
25 /// Builds inventory setup-cost terms.
26 /// </summary>
27 protected override ValueTask BuildTermsAsync(
28 LotSizingInstance instance,
30 LinearExpressionBuilder expressionBuilder,
32 CancellationToken cancellationToken)
33 {
34 foreach (
35 Inventory inventory
36 in instance.SupplyChain.Inventories)
37 {
38 if (inventory.FixedSetupCost is null &&
39 inventory.SetupTime is null)
40 {
41 continue;
42 }
43
44 for (
45 int period = 1;
46 period <= instance.PlanningHorizon;
47 period++)
48 {
49 cancellationToken.ThrowIfCancellationRequested();
50
51 var keyBuilder =
54 .Add(
56 inventory.ItemId);
57
59 keyBuilder,
60 inventory.Warehouse);
61
63 context,
64 expressionBuilder,
65 keyBuilder
66 .Add(
68 period)
69 .Build(),
70 inventory.FixedSetupCost?[period] ??
71 0.0);
72 }
73 }
74
75 return ValueTask.CompletedTask;
76 }
77}
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.
override ValueTask BuildTermsAsync(LotSizingInstance instance, MathematicalModelBuildContext context, LinearExpressionBuilder expressionBuilder, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
Builds inventory setup-cost terms.
Creates canonical domain-key fragments shared by standard formulation builders and provides warehouse...
static MathematicalDomainKeyBuilder AddWarehouse(MathematicalDomainKeyBuilder builder, WarehouseReference warehouse)
Adds a warehouse reference using the generic warehouse or plant segment.
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.
Provides the canonical mathematical domain-key categories used to identify lot-sizing decision famili...
const string InventorySetup
Identifies inventory setup decision variables.
Provides the canonical mathematical domain-key segment names used by lot-sizing variables and constra...