3using LotSizingDataModel.Core.PhysicalModel;
4using LotSizingDataModel.Solution;
5using LotSizingDataModel.Solution.Decisions;
50 LotSizingSolution solution,
54 ArgumentNullException.ThrowIfNull(
57 ArgumentNullException.ThrowIfNull(
60 ArgumentNullException.ThrowIfNull(
63 ArgumentNullException.ThrowIfNull(
70 int transportResourceId =
78 WarehouseReference origin =
85 WarehouseReference destination =
92 TransportDecision? decision =
93 solution.TransportDecisions
98 existing.TransportResourceId ==
99 transportResourceId &&
100 existing.Origin.Kind ==
102 existing.Origin.ReferenceId ==
103 origin.ReferenceId &&
104 existing.Destination.Kind ==
106 existing.Destination.ReferenceId ==
107 destination.ReferenceId);
109 if (decision is
null)
111 if (solution.PlanningHorizon <= 0)
113 throw new InvalidOperationException(
114 "The target lot-sizing solution must have a " +
115 "strictly positive planning horizon before " +
116 "transport decisions are mapped.");
120 new TransportDecision(
125 solution.PlanningHorizon);
127 solution.AddTransportDecision(
131 decision.SetTransportedQuantity(
133 variableValue.
Value);
136 private static WarehouseReference ResolveWarehouse(
138 string warehouseSegment,
142 bool hasStandaloneWarehouse =
145 out
int warehouseId);
147 bool hasPlantWarehouse =
152 if (hasStandaloneWarehouse ==
155 throw new InvalidOperationException(
156 $
"A transport domain key must identify exactly " +
157 $
"one {role} warehouse using either " +
158 $
"'{warehouseSegment}' or '{plantSegment}'.");
161 if (hasStandaloneWarehouse)
163 return WarehouseReference
164 .ForStandaloneWarehouse(
168 return WarehouseReference
Stores the value returned by a solver for one mathematical decision variable.
double Value
Gets or sets the value returned by the solver.
Provides the canonical mathematical domain-key categories used to identify lot-sizing decision famili...
const string Transport
Identifies transported-quantity decision variables.
Provides a reusable base implementation for mathematical decision mappers handling one domain-key cat...
Represents a parsed mathematical-model business-domain key.
int GetRequiredInt32(string name)
Gets a required integer segment.
bool TryGetInt32(string name, out int value)
Attempts to get an integer segment.
Provides the canonical mathematical domain-key segment names used by lot-sizing variables and constra...
const string TransportResource
Transport-resource identifier segment.
const string Item
Item or product identifier segment.
const string DestinationWarehouse
Standalone destination-warehouse identifier segment.
const string OriginPlant
Origin-plant identifier segment.
const string DestinationPlant
Destination-plant identifier segment.
const string Period
Period index segment.
const string OriginWarehouse
Standalone origin-warehouse identifier segment.
Provides the shared state and lookup services required while mapping a mathematical solver result bac...
Maps mathematical transport-variable values to transport decisions in a lot-sizing solution.
override void MapValue(MathematicalSolutionMappingContext context, LotSizingSolution solution, MathematicalDomainKey domainKey, MathematicalVariableValue variableValue)
Maps one non-zero transport quantity.
override string Category
Gets the mathematical domain-key category handled by this mapper.