LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
TransportResourceActivationVariableFamilyBuilder.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/// Builds global transport-resource activation variables.
13/// </summary>
16{
17 /// <summary>
18 /// Gets the transport-resource activation family identifier.
19 /// </summary>
20 public override string FamilyId =>
22
23 /// <summary>
24 /// Determines whether resource activation variables are
25 /// enabled.
26 /// </summary>
27 public override bool IsEnabled(
28 LotSizingInstance instance,
30 {
31 ArgumentNullException.ThrowIfNull(instance);
32 ArgumentNullException.ThrowIfNull(options);
33
34 if (!options.IncludeTransport ||
36 {
37 return false;
38 }
39
40 foreach (
41 TransportResource resource
42 in instance.SupplyChain.TransportResources)
43 {
44 if (resource.FixedUsageCost is not null)
45 {
46 return true;
47 }
48 }
49
50 return false;
51 }
52
53 /// <summary>
54 /// Builds global transport-resource activation variables.
55 /// </summary>
56 protected override ValueTask BuildFamilyAsync(
57 LotSizingInstance instance,
60 CancellationToken cancellationToken)
61 {
62 foreach (
63 TransportResource resource
64 in instance.SupplyChain.TransportResources)
65 {
66 if (resource.FixedUsageCost is null)
67 {
68 continue;
69 }
70
71 for (
72 int period = 1;
73 period <= instance.PlanningHorizon;
74 period++)
75 {
76 cancellationToken.ThrowIfCancellationRequested();
77
78 string domainKey =
81 .TransportResourceActivation)
82 .Add(
84 .TransportResource,
85 resource.Id)
86 .Add(
88 period)
89 .Build();
90
92 context,
93 $"YR_r{resource.Id}_t{period}",
94 domainKey,
95 $"Activation of transport resource " +
96 $"{resource.Id} in period {period}.");
97 }
98 }
99
100 return ValueTask.CompletedTask;
101 }
102}
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 variable-registration helpers for one variable family of the standard ...
static MathematicalVariable AddBinaryVariable(MathematicalModelBuildContext context, string name, string domainKey, string description="")
Creates and registers one binary variable.
override ValueTask BuildFamilyAsync(LotSizingInstance instance, MathematicalModelBuildContext context, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
Builds global transport-resource activation variables.
override bool IsEnabled(LotSizingInstance instance, StandardLotSizingFormulationOptions options)
Determines whether resource activation variables are enabled.
Provides the canonical mathematical domain-key categories used to identify lot-sizing decision famili...
const string TransportResourceActivation
Identifies transport-resource activation decision variables.
Provides the canonical mathematical domain-key segment names used by lot-sizing variables and constra...