LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
SolverProgressRecordingOptions.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
3
5
6/// <summary>
7/// Configures how solver progress snapshots are retained during
8/// an optimization run.
9/// </summary>
10[Serializable]
11[XmlType(TypeName = "solverProgressRecordingOptions")]
13{
14 /// <summary>
15 /// Initializes progress-recording options with recommended
16 /// defaults.
17 /// </summary>
19 {
20 Mode =
21 SolverProgressRecordingMode.SignificantChanges;
22
24 1.0;
25
27 100;
28
30 0.0;
31
33 0.0;
34
36 0.0001;
37
39 10000;
40 }
41
42 /// <summary>
43 /// Gets or sets the progress-recording mode.
44 /// </summary>
45 [XmlAttribute("mode")]
47 {
48 get;
49 set;
50 }
51
52 /// <summary>
53 /// Gets or sets the minimum elapsed-time interval, in
54 /// seconds, between two retained snapshots when
55 /// <see cref="SolverProgressRecordingMode.TimeInterval"/>
56 /// is selected.
57 /// </summary>
58 [XmlAttribute("timeIntervalSeconds")]
59 public double TimeIntervalSeconds
60 {
61 get;
62 set;
63 }
64
65 /// <summary>
66 /// Gets or sets the minimum number of newly explored nodes
67 /// between two retained snapshots when
68 /// <see cref="SolverProgressRecordingMode.NodeInterval"/>
69 /// is selected.
70 /// </summary>
71 [XmlAttribute("nodeInterval")]
72 public long NodeInterval
73 {
74 get;
75 set;
76 }
77
78 /// <summary>
79 /// Gets or sets the minimum absolute incumbent-objective
80 /// change considered significant.
81 /// </summary>
82 [XmlAttribute("minimumObjectiveChange")]
84 {
85 get;
86 set;
87 }
88
89 /// <summary>
90 /// Gets or sets the minimum absolute best-bound change
91 /// considered significant.
92 /// </summary>
93 [XmlAttribute("minimumBoundChange")]
94 public double MinimumBoundChange
95 {
96 get;
97 set;
98 }
99
100 /// <summary>
101 /// Gets or sets the minimum absolute relative-gap change
102 /// considered significant.
103 /// </summary>
104 [XmlAttribute("minimumRelativeGapChange")]
106 {
107 get;
108 set;
109 }
110
111 /// <summary>
112 /// Gets or sets the maximum number of progress points that
113 /// may be retained.
114 /// </summary>
115 /// <remarks>
116 /// A value of zero disables the limit.
117 /// </remarks>
118 [XmlAttribute("maximumRecordedPointCount")]
120 {
121 get;
122 set;
123 }
124
125 /// <summary>
126 /// Validates the progress-recording options.
127 /// </summary>
128 /// <exception cref="InvalidOperationException">
129 /// Thrown when one or more option values are invalid.
130 /// </exception>
131 public void EnsureValid()
132 {
133 if (TimeIntervalSeconds < 0.0 ||
134 double.IsNaN(
136 double.IsInfinity(
138 {
139 throw new InvalidOperationException(
140 "The progress-recording time interval must be " +
141 "a finite non-negative number.");
142 }
143
144 if (NodeInterval < 0)
145 {
146 throw new InvalidOperationException(
147 "The progress-recording node interval cannot " +
148 "be negative.");
149 }
150
151 ValidateFiniteNonNegativeValue(
153 nameof(MinimumObjectiveChange));
154
155 ValidateFiniteNonNegativeValue(
157 nameof(MinimumBoundChange));
158
159 ValidateFiniteNonNegativeValue(
162
164 {
165 throw new InvalidOperationException(
166 "The maximum recorded-point count cannot be " +
167 "negative.");
168 }
169
170 if (Mode ==
171 SolverProgressRecordingMode.TimeInterval &&
172 TimeIntervalSeconds <= 0.0)
173 {
174 throw new InvalidOperationException(
175 "A strictly positive time interval is required " +
176 "when time-interval progress recording is " +
177 "selected.");
178 }
179
180 if (Mode ==
181 SolverProgressRecordingMode.NodeInterval &&
182 NodeInterval <= 0)
183 {
184 throw new InvalidOperationException(
185 "A strictly positive node interval is required " +
186 "when node-interval progress recording is " +
187 "selected.");
188 }
189 }
190
191 private static void ValidateFiniteNonNegativeValue(
192 double value,
193 string propertyName)
194 {
195 if (value < 0.0 ||
196 double.IsNaN(
197 value) ||
198 double.IsInfinity(
199 value))
200 {
201 throw new InvalidOperationException(
202 $"{propertyName} must be a finite " +
203 "non-negative number.");
204 }
205 }
206}
double TimeIntervalSeconds
Gets or sets the minimum elapsed-time interval, in seconds, between two retained snapshots when Solve...
double MinimumObjectiveChange
Gets or sets the minimum absolute incumbent-objective change considered significant.
long NodeInterval
Gets or sets the minimum number of newly explored nodes between two retained snapshots when SolverPro...
double MinimumRelativeGapChange
Gets or sets the minimum absolute relative-gap change considered significant.
SolverProgressRecordingMode Mode
Gets or sets the progress-recording mode.
int MaximumRecordedPointCount
Gets or sets the maximum number of progress points that may be retained.
double MinimumBoundChange
Gets or sets the minimum absolute best-bound change considered significant.
SolverProgressRecordingOptions()
Initializes progress-recording options with recommended defaults.
SolverProgressRecordingMode
Defines how solver progress snapshots are retained in the solution convergence history.