LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
WarehouseResourceCostObjectiveTermBuilder.cs
Go to the documentation of this file.
1using System;
2using System.Threading;
3using System.Threading.Tasks;
4using LotSizingDataModel.Instance;
7
9
10/// <summary>
11/// Adds fixed warehouse activation costs.
12/// </summary>
15{
16 /// <summary>
17 /// Gets the objective-term family identifier.
18 /// </summary>
19 public override string TermFamilyId =>
20 "warehouseResourceCost";
21
22 /// <summary>
23 /// Determines whether activation costs are enabled.
24 /// </summary>
25 public override bool IsEnabled(
26 LotSizingInstance instance,
28 {
29 ArgumentNullException.ThrowIfNull(instance);
30 ArgumentNullException.ThrowIfNull(options);
31
32 return options.IncludeResourceActivation;
33 }
34
35 /// <summary>
36 /// Builds fixed warehouse activation cost terms.
37 /// </summary>
38 protected override ValueTask BuildTermsAsync(
39 LotSizingInstance instance,
41 LinearExpressionBuilder expressionBuilder,
43 CancellationToken cancellationToken)
44 {
45 foreach (
46 var entry
48 .EnumerateWarehouses(
49 instance.SupplyChain))
50 {
51 if (entry.Warehouse.FixedUsageCost is null)
52 {
53 continue;
54 }
55
56 for (
57 int period = 1;
58 period <= instance.PlanningHorizon;
59 period++)
60 {
61 cancellationToken.ThrowIfCancellationRequested();
62
63 var keyBuilder =
66 .WarehouseActivation);
67
69 keyBuilder,
70 entry.Reference);
71
73 context,
74 expressionBuilder,
75 keyBuilder
76 .Add(
78 period)
79 .Build(),
80 entry.Warehouse.FixedUsageCost[period]);
81 }
82 }
83
84 return ValueTask.CompletedTask;
85 }
86}
Provides a fluent builder for linear expressions.
Builds stable business-domain keys for mathematical variables and constraints.
Provides the shared state required while constructing a solver-independent mathematical model.
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.
Enumerates physical resources together with the canonical references required by the mathematical for...
Configures the standard solver-independent mixed-integer lot-sizing formulation.
bool IncludeResourceActivation
Gets or sets whether resource activations are included.
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.
override bool IsEnabled(LotSizingInstance instance, StandardLotSizingFormulationOptions options)
Determines whether activation costs are enabled.
override ValueTask BuildTermsAsync(LotSizingInstance instance, MathematicalModelBuildContext context, LinearExpressionBuilder expressionBuilder, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
Builds fixed warehouse activation cost terms.
Provides the canonical mathematical domain-key categories used to identify lot-sizing decision famili...
Provides the canonical mathematical domain-key segment names used by lot-sizing variables and constra...