LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
ClosedLoopLotSizingSolutionMapper.cs
Go to the documentation of this file.
1using LotSizingDataModel.Instance.ClosedLoop;
2using LotSizingDataModel.Solution;
3using LotSizingDataModel.Solution.Decisions;
6
8
9/// <summary>
10/// Maps alpha.39 mathematical closed-loop decisions into the
11/// normalized LotSizingSolution extension.
12/// </summary>
14{
15 public void Map(
16 IReadOnlyList<ClosedLoopReturnStream> streams,
19 LotSizingSolution solution)
20 {
21 ArgumentNullException.ThrowIfNull(streams);
22 ArgumentNullException.ThrowIfNull(model);
23 ArgumentNullException.ThrowIfNull(solveResult);
24 ArgumentNullException.ThrowIfNull(solution);
25
26 IReadOnlyList<ClosedLoopDecisionSnapshot> snapshots =
28 .Project(
29 streams,
30 model,
31 solveResult);
32
33 solution.ClosedLoopDecisions.Clear();
34
35 foreach (IGrouping<int, ClosedLoopDecisionSnapshot> group
36 in snapshots.GroupBy(
37 snapshot =>
38 snapshot.ReturnStreamId))
39 {
40 var decision =
41 new ClosedLoopDecision(
42 group.Key,
43 solution.PlanningHorizon);
44
45 foreach (ClosedLoopDecisionSnapshot snapshot
46 in group)
47 {
48 decision.RecoveryInputs[snapshot.Period] =
49 snapshot.RecoveryInput;
50
51 decision.DisposalQuantities[snapshot.Period] =
52 snapshot.DisposalQuantity;
53
54 decision.RecoveredOutputs[snapshot.Period] =
55 snapshot.RecoveredOutput;
56 }
57
58 solution.ClosedLoopDecisions.Add(
59 decision);
60 }
61
62 if (!solution.HasValidClosedLoopDecisions)
63 {
64 throw new InvalidOperationException(
65 "Mapped closed-loop decisions are not internally valid.");
66 }
67 }
68}
Stores the solver result for a solver-independent mathematical model.
IReadOnlyList< ClosedLoopDecisionSnapshot > Project(IReadOnlyList< ClosedLoopReturnStream > streams, MathematicalModel model, MathematicalModelSolveResult solveResult)
Maps alpha.39 mathematical closed-loop decisions into the normalized LotSizingSolution extension.
void Map(IReadOnlyList< ClosedLoopReturnStream > streams, MathematicalModel model, MathematicalModelSolveResult solveResult, LotSizingSolution solution)
Represents a solver-independent mathematical optimization model.