LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
InventoryCostObjectiveTermBuilder.cs
Go to the documentation of this file.
1using System.Threading;
2using System.Threading.Tasks;
3using LotSizingDataModel.Core.Relationships;
4using LotSizingDataModel.Instance;
7
9
10/// <summary>
11/// Adds inventory holding or usage costs to the standard
12/// objective.
13/// </summary>
16{
17 /// <summary>
18 /// Gets the objective-term family identifier.
19 /// </summary>
20 public override string TermFamilyId =>
21 "inventoryCost";
22
23 /// <summary>
24 /// Builds inventory cost terms.
25 /// </summary>
26 protected override ValueTask BuildTermsAsync(
27 LotSizingInstance instance,
29 LinearExpressionBuilder expressionBuilder,
31 CancellationToken cancellationToken)
32 {
33 foreach (
34 Inventory inventory
35 in instance.SupplyChain.Inventories)
36 {
37 for (
38 int period = 1;
39 period <= instance.PlanningHorizon;
40 period++)
41 {
42 cancellationToken.ThrowIfCancellationRequested();
43
44 var keyBuilder =
47 .Add(
49 inventory.ItemId);
50
52 keyBuilder,
53 inventory.Warehouse);
54
56 context,
57 expressionBuilder,
58 keyBuilder
59 .Add(
61 period)
62 .Build(),
63 inventory.UnitUsageCost?[period] ??
64 0.0);
65 }
66 }
67
68 return ValueTask.CompletedTask;
69 }
70}
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.
Adds inventory holding or usage costs to the standard objective.
override ValueTask BuildTermsAsync(LotSizingInstance instance, MathematicalModelBuildContext context, LinearExpressionBuilder expressionBuilder, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
Builds inventory 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 Inventory
Identifies inventory-level decision variables.
Provides the canonical mathematical domain-key segment names used by lot-sizing variables and constra...