ULSAlgorithms 1.1.0-g3e5595996d
High-performance exact and heuristic algorithms for uncapacitated lot sizing
Loading...
Searching...
No Matches
GeneralLsCutSeparator.cs
Go to the documentation of this file.
5
7
8/// <summary>
9/// Exact combinatorial separation of the classical general ULS (l,S)
10/// inequalities.
11/// </summary>
12/// <remarks>
13/// <para>
14/// For each prefix ending in l, the classical inequality is written as
15///
16/// sum(j in S) x[j] + sum(j in L minus S) d[j,l] y[j] &gt;= d[0,l].
17///
18/// For fixed l the most violated member is obtained independently for every
19/// period j by choosing the smaller of x[j] and d[j,l] y[j]. Therefore one
20/// candidate per l gives exact separation over the exponential S-family.
21/// </para>
22/// <para>
23/// Time complexity: O(T^2). Additional working memory: O(T), excluding the
24/// returned cuts.
25/// </para>
26/// <para>
27/// Scientific source: I. Barany, T.J. Van Roy, L.A. Wolsey,
28/// "Uncapacitated lot-sizing: the convex hull of solutions",
29/// Mathematical Programming Study 22 (1984), 32-43,
30/// DOI 10.1007/BFb0121006.
31/// </para>
32/// </remarks>
33public sealed class GeneralLsCutSeparator :
35{
36 /// <inheritdoc />
37 public string Name =>
38 "General exact (l,S) separator";
39
40 /// <inheritdoc />
42 CutSeparationMethod.General;
43
44 /// <inheritdoc />
45 public bool IsApplicable(
46 UlsProblem problem)
47 {
48 ArgumentNullException.ThrowIfNull(problem);
49 return true;
50 }
51
52 /// <inheritdoc />
53 public IReadOnlyList<LsSeparatedCut> Separate(
54 UlsProblem problem,
55 UlsFormulation formulation,
56 IReadOnlyDictionary<int, double> variableValues)
57 {
58 ArgumentNullException.ThrowIfNull(problem);
59 ArgumentNullException.ThrowIfNull(formulation);
60 ArgumentNullException.ThrowIfNull(variableValues);
61
63 formulation);
64
65 double[] cumulativeDemand =
67 problem);
68
69 var cuts =
70 new List<LsSeparatedCut>(
71 problem.Horizon);
72
73 for (int l = 0;
74 l < problem.Horizon;
75 l++)
76 {
77 double rhs =
78 cumulativeDemand[l];
79
80 if (rhs == 0.0)
81 {
82 continue;
83 }
84
85 var s =
86 new List<int>(
87 l + 1);
88
89 var coefficients =
90 new List<CutCoefficient>(
91 l + 1);
92
93 double lhs = 0.0;
94
95 for (int period = 0;
96 period <= l;
97 period++)
98 {
99 double x =
101 formulation.Variables.Production,
102 period,
103 variableValues,
104 "production");
105
106 double y =
108 formulation.Variables.Setup,
109 period,
110 variableValues,
111 "setup");
112
113 double demandToL =
115 cumulativeDemand,
116 period,
117 l);
118
119 double setupContribution =
120 demandToL * y;
121
122 if (x <= setupContribution)
123 {
124 s.Add(period);
125
126 coefficients.Add(
127 new CutCoefficient(
129 formulation,
130 formulation.Variables.Production,
131 period,
132 "production"),
133 1.0));
134
135 lhs += x;
136 }
137 else
138 {
139 if (demandToL != 0.0)
140 {
141 coefficients.Add(
142 new CutCoefficient(
144 formulation,
145 formulation.Variables.Setup,
146 period,
147 "setup"),
148 demandToL));
149 }
150
151 lhs +=
152 setupContribution;
153 }
154 }
155
156 if (coefficients.Count == 0)
157 {
158 continue;
159 }
160
161 double violation =
162 rhs - lhs;
163
164 var definition =
165 new LsCutDefinition(
166 l,
167 s,
168 coefficients,
169 LinearConstraintSense.GreaterOrEqual,
170 rhs);
171
172 cuts.Add(
173 new LsSeparatedCut(
174 definition,
175 violation,
177 violation,
178 coefficients)));
179 }
180
181 return cuts;
182 }
183}
Solver-independent definition of one ULS (l,S) inequality.
Exact combinatorial separation of the classical general ULS (l,S) inequalities.
IReadOnlyList< LsSeparatedCut > Separate(UlsProblem problem, UlsFormulation formulation, IReadOnlyDictionary< int, double > variableValues)
Generates the separator's candidate inequalities at one LP point.
bool IsApplicable(UlsProblem problem)
Tests whether the separator is applicable to the problem.
CutSeparationMethod Method
Gets the traceability method identifier.
static void RequireAggregateVariables(UlsFormulation formulation)
static string GetVariableName(UlsFormulation formulation, IReadOnlyDictionary< int, int > semanticMap, int period, string family)
static double GetSemanticValue(IReadOnlyDictionary< int, int > semanticMap, int period, IReadOnlyDictionary< int, double > values, string family)
static double Efficacy(double violation, IEnumerable< CutCoefficient > coefficients)
static double IntervalDemand(double[] cumulativeDemand, int first, int last)
One candidate (l,S) inequality produced by a separation procedure.
Solver-independent ULS mathematical formulation plus semantic variable map.
UlsFormulationVariableMap Variables
Gets semantic variable mappings.
IReadOnlyDictionary< int, int > Setup
Gets setup-variable ids by period.
IReadOnlyDictionary< int, int > Production
Gets production-variable ids by period.
Represents a validated classical uncapacitated lot-sizing problem.
Definition UlsProblem.cs:23
int Horizon
Gets the number of planning periods.
Definition UlsProblem.cs:82
Separates classical ULS (l,S) inequalities from a fractional aggregate lot-sizing solution.
LinearConstraintSense
Identifies the sense of a generated linear inequality.
CutSeparationMethod
Identifies the separation procedure that generated a cut.
Stores one nonzero coefficient of a generated linear inequality.