28 public string Name =>
"Chiu-Ting modified Part-Period Balancing";
37 CancellationToken cancellationToken =
default)
39 ArgumentNullException.ThrowIfNull(problem);
40 cancellationToken.ThrowIfCancellationRequested();
44 var buffer = ArrayPool<int>.Shared.Rent(horizon);
48 var cycleEnds = buffer.AsSpan(0, horizon);
59 ? double.PositiveInfinity
67 while (start < horizon)
69 cancellationToken.ThrowIfCancellationRequested();
71 if (
double.IsPositiveInfinity(epp))
73 cycleEnds[start] = horizon - 1;
78 var partPeriods = 0.0;
79 var bestDifference = epp;
81 for (var end = start + 1; end < horizon; end++)
87 if (!
double.IsFinite(partPeriods))
89 throw new ArithmeticException(
90 "Numerical overflow while evaluating modified PPB.");
94 Math.Abs(epp - partPeriods);
96 if (difference < bestDifference ||
97 (difference == bestDifference &&
100 bestDifference = difference;
104 if (partPeriods >= epp)
110 cycleEnds[start] = bestEnd;
118 cancellationToken.ThrowIfCancellationRequested();
132 ArrayPool<int>.Shared.Return(
Implements the modified Part-Period Balancing (mv-PPB) heuristic of Chiu, Ting and Chiu.
UlsSolverKind Kind
Gets the broad family of the solver.
static bool IsApplicable(UlsProblem problem)
UlsSolveResult Solve(UlsProblem problem, CancellationToken cancellationToken=default)
Solves an uncapacitated lot-sizing problem.
string Name
Gets the stable human-readable name of the solver.
Shared applicability checks for classical stationary-cost lot-sizing heuristics.
static void ThrowIfNotStationary(UlsProblem problem, string solverName)
static bool HasStationaryRelevantCosts(UlsProblem problem)
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.
int Horizon
Gets the number of planning periods.
ReadOnlySpan< double > HoldingCosts
Gets end-of-period unit holding costs by period.
ReadOnlySpan< double > Demands
Gets demand by period.
ReadOnlySpan< double > SetupCosts
Gets fixed setup costs by period.
Represents the outcome returned by a ULS solution strategy.
Defines the common strategy contract implemented by every ULS solver.
UlsSolverKind
Identifies the broad family of a ULS solution strategy.