ULSAlgorithms 1.1.0-g3e5595996d
High-performance exact and heuristic algorithms for uncapacitated lot sizing
Loading...
Searching...
No Matches
AggregateInventoryFormulationBuilder.cs
Go to the documentation of this file.
4
6
7/// <summary>
8/// Builds the classical aggregate ULS mixed-integer formulation with production,
9/// setup and end-of-period inventory variables.
10/// </summary>
11/// <remarks>
12/// <para>
13/// The formulation uses inventory-balance equalities and the tight period-wise
14/// uncapacitated big-M bound x[t] &lt;= D[t..T-1] y[t].
15/// </para>
16/// <para>
17/// Literature context: the classical ULS model originates with Wagner and
18/// Whitin (1958). The aggregate/disaggregate/shortest-path/inventory-eliminated
19/// taxonomy is summarized by Brahimi, Dauzère-Pérès, Najid and Nordli (2006),
20/// "Single item lot sizing problems", EJOR 168(1), 1-16,
21/// DOI 10.1016/j.ejor.2004.01.054.
22/// </para>
23/// </remarks>
26{
27 /// <inheritdoc />
28 public string Name =>
29 "Aggregate inventory-balance formulation";
30
31 /// <inheritdoc />
33 UlsFormulationKind.AggregateInventory;
34
35 /// <inheritdoc />
36 public bool IsApplicable(
37 UlsProblem problem)
38 {
39 ArgumentNullException.ThrowIfNull(problem);
40 return true;
41 }
42
43 /// <inheritdoc />
45 UlsProblem problem)
46 {
47 ArgumentNullException.ThrowIfNull(problem);
48
49 int horizon =
50 problem.Horizon;
51
52 double[] suffixDemand =
54
55 var model =
57
58 var production =
59 new Dictionary<int, int>();
60 var setup =
61 new Dictionary<int, int>();
62 var inventory =
63 new Dictionary<int, int>();
64
65 for (int period = 0;
66 period < horizon;
67 period++)
68 {
69 int x =
70 model.AddVariable(
71 $"x[{period}]",
72 LinearVariableType.Continuous,
73 0.0,
74 suffixDemand[period]);
75
76 int y =
77 model.AddVariable(
78 $"y[{period}]",
79 LinearVariableType.Binary,
80 0.0,
81 1.0);
82
83 double inventoryUpperBound =
84 period == horizon - 1
85 ? 0.0
86 : suffixDemand[period + 1];
87
88 int i =
89 model.AddVariable(
90 $"I[{period}]",
91 LinearVariableType.Continuous,
92 0.0,
93 inventoryUpperBound);
94
95 production.Add(period, x);
96 setup.Add(period, y);
97 inventory.Add(period, i);
98
99 model.AddObjectiveTerm(
100 x,
101 problem.UnitProductionCosts[period]);
102
103 model.AddObjectiveTerm(
104 y,
105 problem.SetupCosts[period]);
106
107 model.AddObjectiveTerm(
108 i,
109 problem.HoldingCosts[period]);
110 }
111
112 for (int period = 0;
113 period < horizon;
114 period++)
115 {
116 var balance =
117 new List<LinearTerm>();
118
119 if (period > 0)
120 {
121 balance.Add(
122 new LinearTerm(
123 inventory[period - 1],
124 1.0));
125 }
126
127 balance.Add(
128 new LinearTerm(
129 production[period],
130 1.0));
131
132 balance.Add(
133 new LinearTerm(
134 inventory[period],
135 -1.0));
136
137 model.AddConstraint(
138 $"balance[{period}]",
139 balance,
141 problem.Demands[period]);
142
143 model.AddConstraint(
144 $"setup-link[{period}]",
145 [
146 new LinearTerm(
147 production[period],
148 1.0),
149 new LinearTerm(
150 setup[period],
151 -suffixDemand[period])
152 ],
153 LinearConstraintSense.LessOrEqual,
154 0.0);
155 }
156
157 return new UlsFormulation(
158 Kind,
159 "Classical aggregate ULS formulation; Wagner & Whitin (1958), " +
160 "DOI 10.1287/mnsc.5.1.89; formulation taxonomy in Brahimi et al. " +
161 "(2006), DOI 10.1016/j.ejor.2004.01.054.",
162 model.Build(
163 "ULS-Aggregate-Inventory"),
165 production,
166 setup,
167 inventory));
168 }
169}
Builds the classical aggregate ULS mixed-integer formulation with production, setup and end-of-period...
UlsFormulation Build(UlsProblem problem)
Builds the portable formulation.
bool IsApplicable(UlsProblem problem)
Tests whether the formulation is valid for the supplied costs.
static double[] BuildSuffixDemand(UlsProblem problem)
Solver-independent ULS mathematical formulation plus semantic variable map.
Maps semantic ULS decisions to solver-independent variable identifiers.
Represents a validated classical uncapacitated lot-sizing problem.
Definition UlsProblem.cs:23
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
Builds a solver-independent mathematical-programming formulation of ULS.
UlsFormulationKind
Identifies a mathematical-programming formulation of classical ULS.
LinearVariableType
Identifies the domain of a variable in a portable linear mathematical model.
LinearConstraintSense
Identifies the sense of a portable linear constraint.
Stores one coefficient of a portable linear expression.
Definition LinearTerm.cs:7