ULSAlgorithms 1.1.0-g3e5595996d
High-performance exact and heuristic algorithms for uncapacitated lot sizing
Loading...
Searching...
No Matches
ChiuTingModifiedPartPeriodBalancingSolver.cs
Go to the documentation of this file.
1using System.Buffers;
6
8
9/// <summary>
10/// Implements the modified Part-Period Balancing (mv-PPB) heuristic of
11/// Chiu, Ting and Chiu.
12/// </summary>
13/// <remarks>
14/// <para>
15/// A standard nearest-EPP PPB plan is first generated. The published
16/// post-processing step then tests whether eliminating the final replenishment
17/// order by merging it into the preceding order strictly reduces total
18/// inventory cost.
19/// </para>
20/// <para>
21/// Reference: S. W. Chiu, C.-K. Ting and Y. P. Chiu,
22/// "A modified version of the part period lot-sizing heuristic",
23/// International Journal for Engineering Modelling 18(1-2), 59-64, 2005.
24/// </para>
25/// </remarks>
27{
28 public string Name => "Chiu-Ting modified Part-Period Balancing";
29
30 public UlsSolverKind Kind => UlsSolverKind.Heuristic;
31
32 public static bool IsApplicable(UlsProblem problem) =>
34
36 UlsProblem problem,
37 CancellationToken cancellationToken = default)
38 {
39 ArgumentNullException.ThrowIfNull(problem);
40 cancellationToken.ThrowIfCancellationRequested();
42
43 var horizon = problem.Horizon;
44 var buffer = ArrayPool<int>.Shared.Rent(horizon);
45
46 try
47 {
48 var cycleEnds = buffer.AsSpan(0, horizon);
49 cycleEnds.Fill(-1);
50
51 var demands = problem.Demands;
52 var holdingCost =
53 horizon > 1
54 ? problem.HoldingCosts[0]
55 : 0.0;
56
57 var epp =
58 holdingCost == 0.0
59 ? double.PositiveInfinity
60 : problem.SetupCosts[0] / holdingCost;
61
62 var start =
64 demands,
65 0);
66
67 while (start < horizon)
68 {
69 cancellationToken.ThrowIfCancellationRequested();
70
71 if (double.IsPositiveInfinity(epp))
72 {
73 cycleEnds[start] = horizon - 1;
74 break;
75 }
76
77 var bestEnd = start;
78 var partPeriods = 0.0;
79 var bestDifference = epp;
80
81 for (var end = start + 1; end < horizon; end++)
82 {
83 partPeriods +=
84 (end - start) *
85 demands[end];
86
87 if (!double.IsFinite(partPeriods))
88 {
89 throw new ArithmeticException(
90 "Numerical overflow while evaluating modified PPB.");
91 }
92
93 var difference =
94 Math.Abs(epp - partPeriods);
95
96 if (difference < bestDifference ||
97 (difference == bestDifference &&
98 end > bestEnd))
99 {
100 bestDifference = difference;
101 bestEnd = end;
102 }
103
104 if (partPeriods >= epp)
105 {
106 break;
107 }
108 }
109
110 cycleEnds[start] = bestEnd;
111
112 start =
114 demands,
115 bestEnd + 1);
116 }
117
118 cancellationToken.ThrowIfCancellationRequested();
119
121 problem,
122 cycleEnds);
123
125 problem,
126 cycleEnds,
127 Name,
128 cancellationToken);
129 }
130 finally
131 {
132 ArrayPool<int>.Shared.Return(
133 buffer,
134 clearArray: false);
135 }
136 }
137}
Implements the modified Part-Period Balancing (mv-PPB) heuristic of Chiu, Ting and Chiu.
UlsSolveResult Solve(UlsProblem problem, CancellationToken cancellationToken=default)
Solves an uncapacitated lot-sizing problem.
Shared applicability checks for classical stationary-cost lot-sizing heuristics.
static void ThrowIfNotStationary(UlsProblem problem, string solverName)
static int FindNextPositiveDemand(ReadOnlySpan< double > demands, int start)
Builds and validates a zero-backlogging heuristic solution from a set of replenishment cycles.
static UlsSolveResult Build(UlsProblem problem, ReadOnlySpan< int > cycleEnds, string solverName, CancellationToken cancellationToken)
Applies the published final-lot merge test used by the modified LUC and modified PPB heuristics.
static bool TryMergeLastLot(UlsProblem problem, Span< int > cycleEnds)
Eliminates the final replenishment lot when moving its complete demand to the preceding replenishment...
Represents a validated classical uncapacitated lot-sizing problem.
Definition UlsProblem.cs:23
int Horizon
Gets the number of planning periods.
Definition UlsProblem.cs:82
ReadOnlySpan< double > HoldingCosts
Gets end-of-period unit holding costs by period.
ReadOnlySpan< double > Demands
Gets demand by period.
Definition UlsProblem.cs:92
ReadOnlySpan< double > SetupCosts
Gets fixed setup costs by period.
Definition UlsProblem.cs:97
Represents the outcome returned by a ULS solution strategy.
Defines the common strategy contract implemented by every ULS solver.
Definition IUlsSolver.cs:14
UlsSolverKind
Identifies the broad family of a ULS solution strategy.