ULSAlgorithms 1.1.0-g3e5595996d
High-performance exact and heuristic algorithms for uncapacitated lot sizing
Loading...
Searching...
No Matches
PartPeriodSimplifiedSolver.cs
Go to the documentation of this file.
1using System.Buffers;
6
8
9/// <summary>
10/// Implements the Part-Period Simplified (PPS) rule, also described as the
11/// Least Total Cost (LTC) no-overshoot part-period rule.
12/// </summary>
13/// <remarks>
14/// <para>
15/// Starting at the first uncovered positive demand, PPS extends the lot while
16/// accumulated part-periods remain less than or equal to the Economic Part
17/// Period A/h. Unlike Part-Period Balancing, PPS does not compare the first
18/// point above A/h with the last point below it.
19/// </para>
20/// <para>
21/// Primary historical source: J. J. DeMatteis,
22/// "An Economic Lot-Sizing Technique I: The Part-Period Algorithm",
23/// IBM Systems Journal 7(1), 30-38, 1968.
24/// </para>
25/// <para>
26/// The explicit distinction between Part-Period Simplified and
27/// Part-Period Balancing is documented in L. Baciarello, M. D'Avino,
28/// R. Onori and M. M. Schiraldi, "Lot Sizing Heuristics Performance",
29/// International Journal of Engineering Business Management 5, 2013,
30/// DOI 10.5772/56004.
31/// </para>
32/// </remarks>
34{
35 public string Name => "Part-Period Simplified";
36
37 public UlsSolverKind Kind => UlsSolverKind.Heuristic;
38
39 public static bool IsApplicable(UlsProblem problem) =>
41
43 UlsProblem problem,
44 CancellationToken cancellationToken = default)
45 {
46 ArgumentNullException.ThrowIfNull(problem);
47 cancellationToken.ThrowIfCancellationRequested();
49
50 var horizon = problem.Horizon;
51 var buffer = ArrayPool<int>.Shared.Rent(horizon);
52
53 try
54 {
55 var cycleEnds = buffer.AsSpan(0, horizon);
56 cycleEnds.Fill(-1);
57
58 var demands = problem.Demands;
59 var holdingCost =
60 horizon > 1
61 ? problem.HoldingCosts[0]
62 : 0.0;
63
64 var epp =
65 holdingCost == 0.0
66 ? double.PositiveInfinity
67 : problem.SetupCosts[0] / holdingCost;
68
69 var start =
71 demands,
72 0);
73
74 while (start < horizon)
75 {
76 cancellationToken.ThrowIfCancellationRequested();
77
78 if (double.IsPositiveInfinity(epp))
79 {
80 cycleEnds[start] = horizon - 1;
81 break;
82 }
83
84 var bestEnd = start;
85 var partPeriods = 0.0;
86
87 for (var end = start + 1; end < horizon; end++)
88 {
89 var candidatePartPeriods =
90 partPeriods +
91 (end - start) *
92 demands[end];
93
94 if (!double.IsFinite(candidatePartPeriods))
95 {
96 throw new ArithmeticException(
97 "Numerical overflow while accumulating part-periods.");
98 }
99
100 if (candidatePartPeriods > epp)
101 {
102 break;
103 }
104
105 partPeriods = candidatePartPeriods;
106 bestEnd = end;
107 }
108
109 cycleEnds[start] = bestEnd;
110
111 start =
113 demands,
114 bestEnd + 1);
115 }
116
118 problem,
119 cycleEnds,
120 Name,
121 cancellationToken);
122 }
123 finally
124 {
125 ArrayPool<int>.Shared.Return(
126 buffer,
127 clearArray: false);
128 }
129 }
130}
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)
Implements the Part-Period Simplified (PPS) rule, also described as the Least Total Cost (LTC) no-ove...
UlsSolverKind Kind
Gets the broad family of the solver.
UlsSolveResult Solve(UlsProblem problem, CancellationToken cancellationToken=default)
Solves an uncapacitated lot-sizing problem.
string Name
Gets the stable human-readable name of the solver.
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.