LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
TransportResourceCostObjectiveTermBuilder.cs
Go to the documentation of this file.
1using System;
2using System.Threading;
3using System.Threading.Tasks;
4using LotSizingDataModel.Core.PhysicalModel;
5using LotSizingDataModel.Instance;
8
10
11/// <summary>
12/// Adds fixed global transport-resource activation costs.
13/// </summary>
16{
17 /// <summary>
18 /// Gets the objective-term family identifier.
19 /// </summary>
20 public override string TermFamilyId =>
21 "transportResourceCost";
22
23 /// <summary>
24 /// Determines whether these costs are enabled.
25 /// </summary>
26 public override bool IsEnabled(
27 LotSizingInstance instance,
29 {
30 ArgumentNullException.ThrowIfNull(instance);
31 ArgumentNullException.ThrowIfNull(options);
32
33 return
34 options.IncludeTransport &&
36 }
37
38 /// <summary>
39 /// Builds transport-resource activation cost terms.
40 /// </summary>
41 protected override ValueTask BuildTermsAsync(
42 LotSizingInstance instance,
44 LinearExpressionBuilder expressionBuilder,
46 CancellationToken cancellationToken)
47 {
48 foreach (
49 TransportResource resource
50 in instance.SupplyChain.TransportResources)
51 {
52 if (resource.FixedUsageCost is null)
53 {
54 continue;
55 }
56
57 for (
58 int period = 1;
59 period <= instance.PlanningHorizon;
60 period++)
61 {
62 cancellationToken.ThrowIfCancellationRequested();
63
64 string domainKey =
67 .TransportResourceActivation)
68 .Add(
70 resource.Id)
71 .Add(
73 period)
74 .Build();
75
77 context,
78 expressionBuilder,
79 domainKey,
80 resource.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.
MathematicalDomainKeyBuilder Add(string name, string value)
Adds a text segment.
Provides the shared state required while constructing a solver-independent mathematical model.
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 these costs are enabled.
override ValueTask BuildTermsAsync(LotSizingInstance instance, MathematicalModelBuildContext context, LinearExpressionBuilder expressionBuilder, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
Builds transport-resource 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...
const string TransportResource
Transport-resource identifier segment.