ULSAlgorithms 1.1.0-g3e5595996d
High-performance exact and heuristic algorithms for uncapacitated lot sizing
Loading...
Searching...
No Matches
InventoryEliminatedFormulationBuilder.cs
Go to the documentation of this file.
4
6
7/// <summary>
8/// Builds an exact aggregate ULS formulation after algebraically eliminating
9/// end-of-period inventory variables.
10/// </summary>
11/// <remarks>
12/// <para>
13/// Inventory is reconstructed from cumulative production:
14/// I[t] = sum(i=0..t) x[i] - sum(i=0..t) d[i].
15/// Nonnegative inventory becomes a cumulative-production inequality, and final
16/// zero inventory becomes equality of total production and total demand.
17/// </para>
18/// <para>
19/// This is the fourth classical formulation family summarized by Brahimi,
20/// Dauzère-Pérès, Najid and Nordli (2006), "Single item lot sizing problems",
21/// EJOR 168(1), 1-16, DOI 10.1016/j.ejor.2004.01.054.
22/// </para>
23/// </remarks>
26{
27 /// <inheritdoc />
28 public string Name =>
29 "Inventory-eliminated aggregate formulation";
30
31 /// <inheritdoc />
33 UlsFormulationKind.InventoryEliminated;
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 double[] cumulativeDemand =
57
58 var model =
60
61 var production =
62 new Dictionary<int, int>();
63 var setup =
64 new Dictionary<int, int>();
65
66 for (int period = 0;
67 period < horizon;
68 period++)
69 {
70 int x =
71 model.AddVariable(
72 $"x[{period}]",
73 LinearVariableType.Continuous,
74 0.0,
75 suffixDemand[period]);
76
77 int y =
78 model.AddVariable(
79 $"y[{period}]",
80 LinearVariableType.Binary,
81 0.0,
82 1.0);
83
84 production.Add(period, x);
85 setup.Add(period, y);
86
87 model.AddObjectiveTerm(
88 y,
89 problem.SetupCosts[period]);
90
91 double xCoefficient =
92 problem.UnitProductionCosts[period];
93
94 for (int inventoryPeriod = period;
95 inventoryPeriod < horizon - 1;
96 inventoryPeriod++)
97 {
98 xCoefficient =
100 xCoefficient,
101 problem.HoldingCosts[inventoryPeriod],
102 "inventory-eliminated production coefficient");
103 }
104
105 model.AddObjectiveTerm(
106 x,
107 xCoefficient);
108
109 model.AddConstraint(
110 $"setup-link[{period}]",
111 [
112 new LinearTerm(
113 x,
114 1.0),
115 new LinearTerm(
116 y,
117 -suffixDemand[period])
118 ],
119 LinearConstraintSense.LessOrEqual,
120 0.0);
121 }
122
123 for (int period = 0;
124 period < horizon - 1;
125 period++)
126 {
127 var cumulativeProduction =
128 new List<LinearTerm>(
129 period + 1);
130
131 for (int source = 0;
132 source <= period;
133 source++)
134 {
135 cumulativeProduction.Add(
136 new LinearTerm(
137 production[source],
138 1.0));
139 }
140
141 model.AddConstraint(
142 $"cumulative-demand[{period}]",
143 cumulativeProduction,
144 LinearConstraintSense.GreaterOrEqual,
145 cumulativeDemand[period]);
146 }
147
148 model.AddConstraint(
149 "total-demand",
150 Enumerable
151 .Range(
152 0,
153 horizon)
154 .Select(
155 period =>
156 new LinearTerm(
157 production[period],
158 1.0)),
160 problem.TotalDemand);
161
162 double objectiveConstant = 0.0;
163
164 for (int period = 0;
165 period < horizon - 1;
166 period++)
167 {
168 objectiveConstant =
170 objectiveConstant,
172 problem.HoldingCosts[period],
173 cumulativeDemand[period],
174 "inventory-eliminated objective constant"),
175 "inventory-eliminated objective constant");
176 }
177
178 return new UlsFormulation(
179 Kind,
180 "Inventory-eliminated classical ULS formulation; taxonomy and " +
181 "algebraic form summarized in Brahimi et al. (2006), DOI " +
182 "10.1016/j.ejor.2004.01.054.",
183 model.Build(
184 "ULS-Inventory-Eliminated",
185 objectiveConstant),
187 production,
188 setup));
189 }
190}
static double[] BuildCumulativeDemand(UlsProblem problem)
static double AddFinite(double left, double right, string operation)
static double MultiplyFinite(double left, double right, string operation)
static double[] BuildSuffixDemand(UlsProblem problem)
Builds an exact aggregate ULS formulation after algebraically eliminating end-of-period inventory var...
bool IsApplicable(UlsProblem problem)
Tests whether the formulation is valid for the supplied costs.
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
double TotalDemand
Gets the total demand over the complete planning horizon.
Definition UlsProblem.cs:87
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 > 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