LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
StandardFormulationDomainKeyFactory.cs
Go to the documentation of this file.
1using System;
2using LotSizingDataModel.Core.PhysicalModel;
5
7
8/// <summary>
9/// Creates canonical domain-key fragments shared by standard
10/// formulation builders and provides warehouse-reference helpers.
11/// </summary>
13{
14 /// <summary>
15 /// Determines whether two warehouse references identify the
16 /// same physical warehouse.
17 /// </summary>
18 /// <param name="left">First warehouse reference.</param>
19 /// <param name="right">Second warehouse reference.</param>
20 /// <returns>
21 /// <see langword="true"/> when kind and reference identifier
22 /// are equal; otherwise, <see langword="false"/>.
23 /// </returns>
24 public static bool AreSameWarehouse(
25 WarehouseReference left,
26 WarehouseReference right)
27 {
28 ArgumentNullException.ThrowIfNull(left);
29 ArgumentNullException.ThrowIfNull(right);
30
31 return
32 left.Kind == right.Kind &&
33 left.ReferenceId == right.ReferenceId;
34 }
35
36 /// <summary>
37 /// Adds a warehouse reference using the generic warehouse
38 /// or plant segment.
39 /// </summary>
42 WarehouseReference warehouse)
43 {
44 ArgumentNullException.ThrowIfNull(builder);
45 ArgumentNullException.ThrowIfNull(warehouse);
46
47 return warehouse.Kind switch
48 {
49 WarehouseReferenceKind.StandaloneWarehouse =>
50 builder.Add(
52 warehouse.ReferenceId),
53
54 WarehouseReferenceKind.PlantWarehouse =>
55 builder.Add(
57 warehouse.ReferenceId),
58
59 _ =>
60 throw new InvalidOperationException(
61 $"Unsupported warehouse-reference kind " +
62 $"'{warehouse.Kind}'.")
63 };
64 }
65
66 /// <summary>
67 /// Adds an origin warehouse reference.
68 /// </summary>
71 WarehouseReference warehouse)
72 {
73 ArgumentNullException.ThrowIfNull(builder);
74 ArgumentNullException.ThrowIfNull(warehouse);
75
76 return warehouse.Kind switch
77 {
78 WarehouseReferenceKind.StandaloneWarehouse =>
79 builder.Add(
81 warehouse.ReferenceId),
82
83 WarehouseReferenceKind.PlantWarehouse =>
84 builder.Add(
86 warehouse.ReferenceId),
87
88 _ =>
89 throw new InvalidOperationException(
90 $"Unsupported origin warehouse-reference kind " +
91 $"'{warehouse.Kind}'.")
92 };
93 }
94
95 /// <summary>
96 /// Adds a destination warehouse reference.
97 /// </summary>
100 WarehouseReference warehouse)
101 {
102 ArgumentNullException.ThrowIfNull(builder);
103 ArgumentNullException.ThrowIfNull(warehouse);
104
105 return warehouse.Kind switch
106 {
107 WarehouseReferenceKind.StandaloneWarehouse =>
108 builder.Add(
110 warehouse.ReferenceId),
111
112 WarehouseReferenceKind.PlantWarehouse =>
113 builder.Add(
115 warehouse.ReferenceId),
116
117 _ =>
118 throw new InvalidOperationException(
119 $"Unsupported destination warehouse-reference " +
120 $"kind '{warehouse.Kind}'.")
121 };
122 }
123}
Builds stable business-domain keys for mathematical variables and constraints.
MathematicalDomainKeyBuilder Add(string name, string value)
Adds a text segment.
Creates canonical domain-key fragments shared by standard formulation builders and provides warehouse...
static bool AreSameWarehouse(WarehouseReference left, WarehouseReference right)
Determines whether two warehouse references identify the same physical warehouse.
static MathematicalDomainKeyBuilder AddWarehouse(MathematicalDomainKeyBuilder builder, WarehouseReference warehouse)
Adds a warehouse reference using the generic warehouse or plant segment.
static MathematicalDomainKeyBuilder AddDestinationWarehouse(MathematicalDomainKeyBuilder builder, WarehouseReference warehouse)
Adds a destination warehouse reference.
static MathematicalDomainKeyBuilder AddOriginWarehouse(MathematicalDomainKeyBuilder builder, WarehouseReference warehouse)
Adds an origin warehouse reference.
Provides the canonical mathematical domain-key segment names used by lot-sizing variables and constra...
const string DestinationWarehouse
Standalone destination-warehouse identifier segment.
const string DestinationPlant
Destination-plant identifier segment.
const string OriginWarehouse
Standalone origin-warehouse identifier segment.