ULSAlgorithms 1.1.0-g3e5595996d
High-performance exact and heuristic algorithms for uncapacitated lot sizing
Loading...
Searching...
No Matches
FacilityLocationFormulationBuilder.cs
Go to the documentation of this file.
4
6
7/// <summary>
8/// Builds the classical disaggregated/facility-location formulation of ULS.
9/// </summary>
10/// <remarks>
11/// <para>
12/// q[t,k] is the amount of demand in period k supplied by a setup in period t,
13/// with t &lt;= k. Demand is assigned exactly once and q[t,k] &lt;= d[k] y[t].
14/// The delivered unit cost contains production cost in t plus holding from t
15/// through k-1.
16/// </para>
17/// <para>
18/// The facility-location connection for economic lot sizing is classically
19/// associated with Krarup and Bilde (1977), "Plant location, Set Covering and
20/// Economic Lot Size", DOI 10.1007/978-3-0348-5936-3_10. The formulation
21/// taxonomy is also reviewed by Brahimi et al. (2006),
22/// DOI 10.1016/j.ejor.2004.01.054.
23/// </para>
24/// </remarks>
27{
28 /// <inheritdoc />
29 public string Name =>
30 "Disaggregated facility-location formulation";
31
32 /// <inheritdoc />
34 UlsFormulationKind.FacilityLocation;
35
36 /// <inheritdoc />
37 public bool IsApplicable(
38 UlsProblem problem)
39 {
40 ArgumentNullException.ThrowIfNull(problem);
41 return true;
42 }
43
44 /// <inheritdoc />
46 UlsProblem problem)
47 {
48 ArgumentNullException.ThrowIfNull(problem);
49
50 int horizon =
51 problem.Horizon;
52
53 var model =
55
56 var setup =
57 new Dictionary<int, int>();
58
59 var q =
60 new Dictionary<(int First, int Second), int>();
61
62 for (int period = 0;
63 period < horizon;
64 period++)
65 {
66 int y =
67 model.AddVariable(
68 $"y[{period}]",
69 LinearVariableType.Binary,
70 0.0,
71 1.0);
72
73 setup.Add(period, y);
74
75 model.AddObjectiveTerm(
76 y,
77 problem.SetupCosts[period]);
78 }
79
80 for (int demandPeriod = 0;
81 demandPeriod < horizon;
82 demandPeriod++)
83 {
84 double demand =
85 problem.Demands[demandPeriod];
86
87 if (demand == 0.0)
88 {
89 continue;
90 }
91
92 var assignment =
93 new List<LinearTerm>(
94 demandPeriod + 1);
95
96 for (int productionPeriod = 0;
97 productionPeriod <= demandPeriod;
98 productionPeriod++)
99 {
100 int variable =
101 model.AddVariable(
102 $"q[{productionPeriod},{demandPeriod}]",
103 LinearVariableType.Continuous,
104 0.0,
105 demand);
106
107 q.Add(
108 (productionPeriod, demandPeriod),
109 variable);
110
111 assignment.Add(
112 new LinearTerm(
113 variable,
114 1.0));
115
116 model.AddConstraint(
117 $"facility-link[{productionPeriod},{demandPeriod}]",
118 [
119 new LinearTerm(
120 variable,
121 1.0),
122 new LinearTerm(
123 setup[productionPeriod],
124 -demand)
125 ],
126 LinearConstraintSense.LessOrEqual,
127 0.0);
128
129 model.AddObjectiveTerm(
130 variable,
132 problem,
133 productionPeriod,
134 demandPeriod));
135 }
136
137 model.AddConstraint(
138 $"demand[{demandPeriod}]",
139 assignment,
141 demand);
142 }
143
144 return new UlsFormulation(
145 Kind,
146 "Disaggregated/facility-location ULS formulation; Krarup & Bilde " +
147 "(1977), DOI 10.1007/978-3-0348-5936-3_10; taxonomy in Brahimi " +
148 "et al. (2006), DOI 10.1016/j.ejor.2004.01.054.",
149 model.Build(
150 "ULS-Facility-Location"),
152 setup: setup,
153 disaggregated: q));
154 }
155}
Builds the classical disaggregated/facility-location formulation of ULS.
UlsFormulation Build(UlsProblem problem)
Builds the portable formulation.
bool IsApplicable(UlsProblem problem)
Tests whether the formulation is valid for the supplied costs.
static double DeliveredUnitCost(UlsProblem problem, int productionPeriod, int demandPeriod)
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
int Horizon
Gets the number of planning periods.
Definition UlsProblem.cs:82
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