LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
InitialInventoryVariableFamilyBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.Relationships;
2using LotSizingDataModel.Instance;
5
7
8/// <summary>
9/// Builds explicit period-zero inventory variables.
10/// </summary>
13{
14 public override string FamilyId =>
16
17 public override bool IsEnabled(
18 LotSizingInstance instance,
20 {
21 ArgumentNullException.ThrowIfNull(instance);
22 ArgumentNullException.ThrowIfNull(options);
23
24 return instance.SupplyChain.Inventories.Any(
25 inventory =>
26 inventory.InitialInventoryDecisionMode ==
27 InitialInventoryDecisionMode.VariableDecision);
28 }
29
30 protected override ValueTask BuildFamilyAsync(
31 LotSizingInstance instance,
34 CancellationToken cancellationToken)
35 {
36 foreach (Inventory inventory in instance.SupplyChain.Inventories)
37 {
38 cancellationToken.ThrowIfCancellationRequested();
39
40 if (inventory.InitialInventoryDecisionMode !=
41 InitialInventoryDecisionMode.VariableDecision)
42 {
43 continue;
44 }
45
46 if (inventory.InitialInventory != 0.0)
47 {
48 throw new InvalidOperationException(
49 "A variable initial-inventory decision cannot coexist " +
50 "with a non-zero fixed InitialInventory value.");
51 }
52
54 context,
55 $"I0_i{inventory.ItemId}_w{inventory.Warehouse.ReferenceId}",
57 double.PositiveInfinity,
58 "Inventory available before period 1.");
59 }
60
61 return ValueTask.CompletedTask;
62 }
63}
Provides the shared state required while constructing a solver-independent mathematical model.
override bool IsEnabled(LotSizingInstance instance, StandardLotSizingFormulationOptions options)
Determines whether this variable family is enabled for the supplied instance and formulation options.
override string FamilyId
Gets the unique identifier of the variable family.
override ValueTask BuildFamilyAsync(LotSizingInstance instance, MathematicalModelBuildContext context, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
Configures the standard solver-independent mixed-integer lot-sizing formulation.
Provides common validation and variable-registration helpers for one variable family of the standard ...
static MathematicalVariable AddNonNegativeContinuousVariable(MathematicalModelBuildContext context, string name, string domainKey, double upperBound=double.PositiveInfinity, string description="")
Creates and registers one continuous non-negative variable.
Provides the canonical mathematical domain-key categories used to identify lot-sizing decision famili...