ULSAlgorithms 1.1.0-g3e5595996d
High-performance exact and heuristic algorithms for uncapacitated lot sizing
Loading...
Searching...
No Matches
CuttingPlaneConvergenceReport.cs
Go to the documentation of this file.
2
3/// <summary>
4/// Summarizes root-bound evolution and separation effort for one exact
5/// cut-and-solve execution.
6/// </summary>
8{
9 private readonly CuttingPlaneIterationStatistics[] _iterations;
10
11 /// <summary>Initializes a convergence report.</summary>
13 IEnumerable<CuttingPlaneIterationStatistics> iterations,
14 double? finalMipObjective)
15 {
16 ArgumentNullException.ThrowIfNull(iterations);
17
18 _iterations =
19 iterations
20 .OrderBy(
21 static item =>
22 item.Iteration)
23 .ToArray();
24
25 if (_iterations
26 .Select(
27 static item =>
28 item.Iteration)
29 .Distinct()
30 .Count() !=
31 _iterations.Length)
32 {
33 throw new ArgumentException(
34 "Iteration identifiers must be unique.",
35 nameof(iterations));
36 }
37
38 if (finalMipObjective.HasValue &&
39 !double.IsFinite(finalMipObjective.Value))
40 {
41 throw new ArgumentOutOfRangeException(
42 nameof(finalMipObjective));
43 }
44
45 FinalMipObjective = finalMipObjective;
46 }
47
48 /// <summary>Gets root iterations in ascending order.</summary>
49 public IReadOnlyList<CuttingPlaneIterationStatistics> Iterations =>
50 _iterations;
51
52 /// <summary>Gets the objective of the first root LP.</summary>
53 public double? InitialLpObjective =>
54 _iterations.Length == 0
55 ? null
56 : _iterations[0].LpObjective;
57
58 /// <summary>Gets the objective of the last solved strengthened root LP.</summary>
59 public double? FinalRootLpObjective =>
60 _iterations.Length == 0
61 ? null
62 : _iterations[^1].LpObjective;
63
64 /// <summary>Gets the final exact MILP objective, when available.</summary>
65 public double? FinalMipObjective { get; }
66
67 /// <summary>Gets absolute improvement of the root lower bound.</summary>
68 public double? RootBoundImprovement =>
69 InitialLpObjective.HasValue &&
70 FinalRootLpObjective.HasValue
71 ? FinalRootLpObjective.Value -
72 InitialLpObjective.Value
73 : null;
74
75 /// <summary>
76 /// Gets the fraction of the initial LP-to-MIP gap closed by root cutting
77 /// planes. Returns null when the denominator is numerically zero.
78 /// </summary>
79 public double? RootGapClosedFraction
80 {
81 get
82 {
83 if (!InitialLpObjective.HasValue ||
84 !FinalRootLpObjective.HasValue ||
85 !FinalMipObjective.HasValue)
86 {
87 return null;
88 }
89
90 double denominator =
91 FinalMipObjective.Value -
93
94 double scale =
95 Math.Max(
96 1.0,
97 Math.Abs(
98 FinalMipObjective.Value));
99
100 if (Math.Abs(denominator) <=
101 1.0e-12 * scale)
102 {
103 return null;
104 }
105
106 return
107 (FinalRootLpObjective.Value -
108 InitialLpObjective.Value) /
109 denominator;
110 }
111 }
112
113 /// <summary>Gets total root LP solver time.</summary>
114 public TimeSpan TotalLpSolveTime =>
115 TimeSpan.FromTicks(
116 _iterations.Sum(
117 static item =>
118 item.LpSolveTime.Ticks));
119
120 /// <summary>Gets total separator time.</summary>
121 public TimeSpan TotalSeparationTime =>
122 TimeSpan.FromTicks(
123 _iterations.Sum(
124 static item =>
125 item.SeparationTime.Ticks));
126
127 /// <summary>Gets total candidate count across root iterations.</summary>
129 _iterations.Sum(
130 static item =>
131 item.GeneratedCandidates);
132
133 /// <summary>Gets total selected cuts across root iterations.</summary>
134 public int TotalSelectedCuts =>
135 _iterations.Sum(
136 static item =>
137 item.SelectedCuts);
138}
int TotalGeneratedCandidates
Gets total candidate count across root iterations.
IReadOnlyList< CuttingPlaneIterationStatistics > Iterations
Gets root iterations in ascending order.
double? FinalMipObjective
Gets the final exact MILP objective, when available.
int TotalSelectedCuts
Gets total selected cuts across root iterations.
CuttingPlaneConvergenceReport(IEnumerable< CuttingPlaneIterationStatistics > iterations, double? finalMipObjective)
Initializes a convergence report.
double? RootGapClosedFraction
Gets the fraction of the initial LP-to-MIP gap closed by root cutting planes. Returns null when the d...
double? FinalRootLpObjective
Gets the objective of the last solved strengthened root LP.
double? InitialLpObjective
Gets the objective of the first root LP.
double? RootBoundImprovement
Gets absolute improvement of the root lower bound.
Numerical convergence statistics for one root cutting-plane iteration.