ULSAlgorithms 1.1.0-g3e5595996d
High-performance exact and heuristic algorithms for uncapacitated lot sizing
Loading...
Searching...
No Matches
LotForLotSolver.cs
Go to the documentation of this file.
1using System.Buffers;
6
8
9/// <summary>
10/// Implements the classical Lot-for-Lot (L4L/LFL) policy.
11/// </summary>
12/// <remarks>
13/// Every positive demand is replenished in its own period. The method is a
14/// standard MRP baseline and is feasible for the complete general
15/// <see cref="UlsProblem"/> cost model.
16/// Time complexity is O(T); auxiliary working memory is O(T).
17/// </remarks>
18public sealed class LotForLotSolver : IUlsSolver
19{
20 public string Name => "Lot-for-Lot";
21
22 public UlsSolverKind Kind => UlsSolverKind.Heuristic;
23
25 UlsProblem problem,
26 CancellationToken cancellationToken = default)
27 {
28 ArgumentNullException.ThrowIfNull(problem);
29 cancellationToken.ThrowIfCancellationRequested();
30
31 var horizon = problem.Horizon;
32 var buffer = ArrayPool<int>.Shared.Rent(horizon);
33
34 try
35 {
36 var cycleEnds = buffer.AsSpan(0, horizon);
37 cycleEnds.Fill(-1);
38
39 var demands = problem.Demands;
40
41 for (var period = 0; period < horizon; period++)
42 {
43 if (demands[period] > 0.0)
44 {
45 cycleEnds[period] = period;
46 }
47 }
48
50 problem,
51 cycleEnds,
52 Name,
53 cancellationToken);
54 }
55 finally
56 {
57 ArrayPool<int>.Shared.Return(buffer, clearArray: false);
58 }
59 }
60}
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 classical Lot-for-Lot (L4L/LFL) policy.
string Name
Gets the stable human-readable name of the solver.
UlsSolveResult Solve(UlsProblem problem, CancellationToken cancellationToken=default)
Solves an uncapacitated lot-sizing problem.
UlsSolverKind Kind
Gets the broad family 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 > Demands
Gets demand by period.
Definition UlsProblem.cs:92
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.