ULSAlgorithms 1.1.0-g3e5595996d
High-performance exact and heuristic algorithms for uncapacitated lot sizing
Loading...
Searching...
No Matches
UlsProblemCharacteristics.cs
Go to the documentation of this file.
2
4
5/// <summary>
6/// Describes inexpensive structural and cost characteristics used to select
7/// an exact ULS solution strategy.
8/// </summary>
9/// <remarks>
10/// The analysis is deliberately independent of solver execution. It can be
11/// reused by benchmarking, orchestration and future learned/empirical selection
12/// policies without changing the common <c>IUlsSolver</c> contract.
13/// </remarks>
14public readonly record struct UlsProblemCharacteristics(
15 int Horizon,
16 double TotalDemand,
17 int PositiveDemandPeriods,
18 bool HasNoSpeculativeMotiveCosts,
19 bool HasConstantSetupCosts,
20 bool HasConstantUnitProductionCosts,
21 bool HasConstantHoldingCosts)
22{
23 /// <summary>
24 /// Gets the fraction of periods carrying strictly positive demand.
25 /// </summary>
26 public double DemandDensity =>
27 Horizon == 0 ? 0.0 : (double)PositiveDemandPeriods / Horizon;
28}
29
30/// <summary>
31/// Computes solver-selection characteristics for a validated ULS problem.
32/// </summary>
33public static class UlsProblemAnalyzer
34{
35 /// <summary>
36 /// Analyzes the problem in one linear pass.
37 /// </summary>
38 /// <param name="problem">The validated ULS problem.</param>
39 /// <returns>A compact immutable characteristic vector.</returns>
40 /// <remarks>
41 /// <para>
42 /// The no-speculative-motive condition is
43 /// <c>p[t] + h[t] &gt;= p[t+1]</c>. Its value is already cached by
44 /// <see cref="UlsProblem"/> during construction, so this analyzer reuses
45 /// the cached value while its linear pass computes the remaining
46 /// characteristics.
47 /// </para>
48 /// <para>
49 /// Algorithmic basis: A. Wagelmans, S. van Hoesel and A. Kolen,
50 /// "Economic Lot Sizing: An O(n log n) Algorithm That Runs in Linear Time
51 /// in the Wagner-Whitin Case", Operations Research 40(S1), S145-S156,
52 /// 1992, DOI: 10.1287/opre.40.1.S145.
53 /// </para>
54 /// </remarks>
56 {
57 ArgumentNullException.ThrowIfNull(problem);
58
59 var horizon = problem.Horizon;
60 var demands = problem.Demands;
61 var setupCosts = problem.SetupCosts;
62 var productionCosts = problem.UnitProductionCosts;
63 var holdingCosts = problem.HoldingCosts;
64
65 var positiveDemandPeriods = 0;
66 var constantSetup = true;
67 var constantProduction = true;
68 var constantHolding = true;
69
70 var firstSetup = setupCosts[0];
71 var firstProduction = productionCosts[0];
72 var firstHolding = holdingCosts[0];
73
74 for (var period = 0; period < horizon; period++)
75 {
76 if (demands[period] > 0.0)
77 {
78 positiveDemandPeriods++;
79 }
80
81 if (setupCosts[period] != firstSetup)
82 {
83 constantSetup = false;
84 }
85
86 if (productionCosts[period] != firstProduction)
87 {
88 constantProduction = false;
89 }
90
91 if (holdingCosts[period] != firstHolding)
92 {
93 constantHolding = false;
94 }
95 }
96
98 horizon,
99 problem.TotalDemand,
100 positiveDemandPeriods,
102 constantSetup,
103 constantProduction,
104 constantHolding);
105 }
106}
Represents a validated classical uncapacitated lot-sizing problem.
Definition UlsProblem.cs:23
double TotalDemand
Gets the total demand over the complete planning horizon.
Definition UlsProblem.cs:87
bool HasNoSpeculativeMotiveCosts
Gets whether the immutable problem satisfies the no-speculative-motive cost condition used by the lin...
ReadOnlySpan< double > UnitProductionCosts
Gets unit production costs by period.
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
Computes solver-selection characteristics for a validated ULS problem.
static UlsProblemCharacteristics Analyze(UlsProblem problem)
Analyzes the problem in one linear pass.
Describes inexpensive structural and cost characteristics used to select an exact ULS solution strate...
double DemandDensity
Gets the fraction of periods carrying strictly positive demand.