Scippy

SoPlex

Sequential object-oriented simPlex

statistics.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the class library */
4 /* SoPlex --- the Sequential object-oriented simPlex. */
5 /* */
6 /* Copyright (C) 1996-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 #include <iostream>
17 #include <assert.h>
18 
19 #include "soplex/statistics.h"
20 #include "soplex/timerfactory.h"
21 
22 namespace soplex
23 {
24 
25 /// default constructor
27 {
28  timerType = ttype;
37  clearAllData();
38 }
39 
40 /// copy constructor
42 {
43  timerType = base.timerType;
52  clearAllData();
53 }
54 
55 /// assignment operator
57 {
58  *readingTime = *(rhs.readingTime);
59  *solvingTime = *(rhs.solvingTime);
61  *simplexTime = *(rhs.simplexTime);
62  *syncTime = *(rhs.syncTime);
63  *transformTime = *(rhs.transformTime);
64  *rationalTime = *(rhs.rationalTime);
66  timerType = rhs.timerType;
71  iterations = rhs.iterations;
74  boundflips = rhs.boundflips;
84 
85  return *this;
86 }
87 
88 /// clears all statistics
90 {
91  readingTime->reset();
93 }
94 
95 /// clears statistics on solving process
97 {
98  solvingTime->reset();
100  simplexTime->reset();
101  syncTime->reset();
102  transformTime->reset();
103  rationalTime->reset();
106  luSolveTimeReal = 0.0;
108  luSolveTimeRational = 0.0;
109  iterations = 0;
110  iterationsPrimal = 0;
112  iterationsPolish = 0;
113  boundflips = 0;
115  luSolvesReal = 0;
118  refinements = 0;
119  stallRefinements = 0;
120  pivotRefinements = 0;
121  feasRefinements = 0;
122  unbdRefinements = 0;
123 
124  callsReducedProb = 0;
125  iterationsInit = 0;
126  iterationsRedProb = 0;
127  iterationsCompProb = 0;
128  numRedProbRows = 0;
129  numRedProbCols = 0;
130  degenPivotsPrimal = 0;
131  degenPivotsDual = 0;
133  degenPivotCandDual = 0;
134  sumDualDegen = 0;
135  sumPrimalDegen = 0;
136  decompBasisCondNum = 0;
137  totalBoundViol = 0;
138  totalRowViol = 0;
139  maxBoundViol = 0;
140  maxRowViol = 0;
141  redProbStatus = 0;
142  compProbStatus = 0;
143  finalCompObj = 0;
145 }
146 
147 /// prints statistics
148 void SoPlex::Statistics::print(std::ostream& os)
149 {
150  Real solTime = solvingTime->time();
151  Real totTime = readingTime->time() + solTime;
152  Real otherTime = solTime - syncTime->time() - transformTime->time() - preprocessingTime->time() -
154 
155  Real avgPrimalDegeneracy = iterationsPrimal > 0 ? sumPrimalDegen / iterationsPrimal : 0.0;
156  Real avgDualDegeneracy = (iterations - iterationsPrimal) > 0 ?
158 
159  SPxOut::setFixed(os, 2);
160 
161  os << "Total time : " << totTime << "\n"
162  << " Reading : " << readingTime->time() << "\n"
163  << " Solving : " << solTime << "\n"
164  << " Preprocessing : " << preprocessingTime->time();
165 
166  if(solTime > 0)
167  os << " (" << 100 * (preprocessingTime->time() / solTime) << "% of solving time)";
168 
169  os << "\n Simplex : " << simplexTime->time();
170 
171  if(solTime > 0)
172  os << " (" << 100 * (simplexTime->time() / solTime) << "% of solving time)";
173 
174  os << "\n Synchronization : " << syncTime->time();
175 
176  if(solTime > 0)
177  os << " (" << 100 * (syncTime->time() / solTime) << "% of solving time)";
178 
179  os << "\n Transformation : " << transformTime->time();
180 
181  if(solTime > 0)
182  os << " (" << 100 * transformTime->time() / solTime << "% of solving time)";
183 
184  os << "\n Rational : " << rationalTime->time();
185 
186  if(solTime > 0)
187  os << " (" << 100 * rationalTime->time() / solTime << "% of solving time)";
188 
189  os << "\n Other : " << otherTime;
190 
191  if(solTime > 0)
192  os << " (" << 100 * otherTime / solTime << "% of solving time)";
193 
194  os << "\nRefinements : " << refinements << "\n"
195  << " Stalling : " << stallRefinements << "\n"
196  << " Pivoting : " << pivotRefinements << "\n"
197  << " Feasibility : " << feasRefinements << "\n"
198  << " Unboundedness : " << unbdRefinements << "\n";
199 
200  os << "Iterations : " << iterations << "\n"
201  << " From scratch : " << iterations - iterationsFromBasis;
202 
203  if(iterations > 0)
204  os << " (" << 100 * double((iterations - iterationsFromBasis)) / double(iterations) << "%)";
205 
206  os << "\n From basis : " << iterationsFromBasis;
207 
208  if(iterations > 0)
209  os << " (" << 100 * double(iterationsFromBasis) / double(iterations) << "%)";
210 
211  os << "\n Primal : " << iterationsPrimal;
212 
213  if(iterations > 0)
214  os << " (" << 100 * double(iterationsPrimal) / double(iterations) << "%)";
215 
216  os << "\n Dual : " << iterations - iterationsPrimal - iterationsPolish;
217 
218  if(iterations > 0)
219  os << " (" << 100 * double((iterations - iterationsPrimal)) / double(iterations) << "%)";
220 
221  os << "\n Bound flips : " << boundflips;
222  os << "\n Sol. polishing : " << iterationsPolish;
223 
224  os << "\nLU factorizations : " << luFactorizationsReal << "\n"
225  << " Factor. frequency : ";
226 
227  if(luFactorizationsReal > 0)
228  os << double(iterations) / double(luFactorizationsReal) << " iterations per factorization\n";
229  else
230  os << "-\n";
231 
232  os << " Factor. time : " << luFactorizationTimeReal << "\n";
233 
234  os << "LU solves : " << luSolvesReal << "\n"
235  << " Solve frequency : ";
236 
237  if(iterations > 0)
238  os << double(luSolvesReal) / double(iterations) << " solves per iteration\n";
239  else
240  os << "-\n";
241 
242  os << " Solve time : " << luSolveTimeReal << "\n";
243 
244  os << "Rat. factorizations : " << luFactorizationsRational << "\n"
245  << " Rat. factor. time : " << luFactorizationTimeRational << "\n"
246  << " Rat. solve time : " << luSolveTimeRational << "\n";
247 
248  os << "Rat. reconstructions: " << rationalReconstructions << "\n"
249  << " Rat. rec. time : " << reconstructionTime->time() << "\n";
250 
251  os << "Degeneracy : \n";
252  os << " Primal Pivots : " << degenPivotsPrimal << "\n";
253  os << " Dual Pivots : " << degenPivotsDual << "\n";
254  os << " Primal Candidates : " << degenPivotCandPrimal << "\n";
255  os << " Dual Candidates : " << degenPivotCandDual << "\n";
256  os << " Average Primal : " << avgPrimalDegeneracy << "\n";
257  os << " Average Dual : " << avgDualDegeneracy << "\n";
258 
259  if(iterationsInit > 0)
260  {
261  os << "Algorithm Iterations: " << callsReducedProb << "\n";
262  os << "Decomp. Iterations : \n";
263  os << " Total : " << iterationsInit + iterationsRedProb << "\n";
264  os << " Initial : " << iterationsInit << "\n";
265  os << " Reduced Problem : " << iterationsRedProb << "\n";
266  os << " Comp. Problem : " << iterationsCompProb << "\n";
267  os << "Red. Problem Size : \n";
268  os << " Rows : " << numRedProbRows << "\n";
269  os << " Columns : " << numRedProbCols << "\n";
270 
271  SPxOut::setScientific(os, 16);
272 
273  os << "Decomp. Basis Cond. : " << decompBasisCondNum << "\n";
274  os << "Decomp Violations : \n";
275  os << " Sum Bound : " << totalBoundViol << "\n";
276  os << " Sum Row : " << totalRowViol << "\n";
277  os << " Max Bound : " << maxBoundViol << "\n";
278  os << " Max Row : " << maxRowViol << "\n";
279 
280  SPxOut::setFixed(os, 2);
281 
282  os << "Red. Problem Status : " << redProbStatus << "\n";
283  os << "Comp. Problem Status: " << compProbStatus << "\n";
284 
285  SPxOut::setScientific(os, 16);
286 
287  os << "Comp. Problem Obj. : " << finalCompObj << "\n";
288  }
289 
291 
292  os << "Numerics :\n";
293  os << " Condition Number : " << finalBasisCondition << "\n";
294 
295 }
296 } // namespace soplex
int unbdRefinements
number of refinement steps during undboundedness test
Definition: statistics.h:113
int callsReducedProb
number of times the reduced problem is solved. This includes the initial solve.
Definition: statistics.h:116
Timer * syncTime
time for synchronization between real and rational LP (included in solving time)
Definition: statistics.h:91
int feasRefinements
number of refinement steps during infeasibility test
Definition: statistics.h:112
Real decompBasisCondNum
the condition number for the basis used to perform the decomposition
Definition: statistics.h:128
int stallRefinements
number of refinement steps without pivots
Definition: statistics.h:110
int numRedProbCols
number of columns in the reduced problem
Definition: statistics.h:121
int iterationsInit
number of iterations in the initial LP
Definition: statistics.h:117
Timer * simplexTime
simplex time
Definition: statistics.h:90
int luSolvesReal
number of (forward and backward) solves with basis matrix in real precision
Definition: statistics.h:106
int refinements
number of refinement steps
Definition: statistics.h:109
int luFactorizationsReal
number of basis matrix factorizations in real precision
Definition: statistics.h:105
Real finalCompObj
the final objective function of the complementary problem
Definition: statistics.h:135
static void setScientific(std::ostream &stream, int precision=8)
Sets the precision of the stream to 16 and the floatfield to scientifix.
Definition: spxout.h:171
TimerFactory class.
int degenPivotCandDual
number of pivoting candidates that will produce a degenerate step in the dual
Definition: statistics.h:125
int compProbStatus
status of the complementary problem
Definition: statistics.h:134
Real luFactorizationTimeReal
time for factorizing bases matrices in real precision
Definition: statistics.h:96
double Real
Definition: spxdefines.h:218
static void setFixed(std::ostream &stream, int precision=8)
Sets the precision of the stream to 8 and the floatfield to fixed.
Definition: spxout.h:177
Timer * rationalTime
time for rational LP solving (included in solving time)
Definition: statistics.h:93
Real maxRowViol
the max row violations in the original problem using the red prob sol
Definition: statistics.h:132
Real sumPrimalDegen
the sum of the rate of primal degeneracy at each iteration
Definition: statistics.h:127
Class for collecting statistical information.
Real maxBoundViol
the max bound violation in the original problem using the red prob sol
Definition: statistics.h:131
Real luSolveTimeRational
time for solving linear systems in rational precision
Definition: statistics.h:99
virtual Real time() const =0
int degenPivotsDual
number of dual degenerate pivots
Definition: statistics.h:123
static Timer * createTimer(Timer::TYPE ttype)
create timers and allocate memory for them
Definition: timerfactory.h:44
int luFactorizationsRational
number of basis matrix factorizations in rational precision
Definition: statistics.h:107
Timer * preprocessingTime
preprocessing time
Definition: statistics.h:89
Real luSolveTimeReal
time for solving linear systems in real precision
Definition: statistics.h:97
Timer * reconstructionTime
time for rational reconstructions
Definition: statistics.h:94
Everything should be within this namespace.
Timer::TYPE timerType
type of timer (user or wallclock)
Definition: statistics.h:95
TYPE
types of timers
Definition: timer.h:99
int iterations
number of iterations/pivots
Definition: statistics.h:100
int boundflips
number of dual bound flips
Definition: statistics.h:104
void clearAllData()
clears all statistics
Definition: statistics.cpp:89
int iterationsRedProb
number of iterations of the reduced problem
Definition: statistics.h:118
void print(std::ostream &os)
prints statistics
Definition: statistics.cpp:148
void clearSolvingData()
clears statistics on solving process
Definition: statistics.cpp:96
Real finalBasisCondition
condition number estimate of the optimal basis matrix
Definition: statistics.h:138
Real totalRowViol
the sum of the row violations in the original problem using the red prob sol
Definition: statistics.h:130
Timer * readingTime
reading time not included in solving time
Definition: statistics.h:87
int iterationsFromBasis
number of iterations from Basis
Definition: statistics.h:102
int iterationsPolish
number of iterations during solution polishing
Definition: statistics.h:103
Statistics & operator=(const Statistics &rhs)
assignment operator
Definition: statistics.cpp:56
Timer * solvingTime
solving time
Definition: statistics.h:88
int degenPivotCandPrimal
number of pivoting candidates that will produce a degenerate step in the primal
Definition: statistics.h:124
Statistics(Timer::TYPE ttype=Timer::USER_TIME)
default constructor
Definition: statistics.cpp:26
int iterationsPrimal
number of iterations with Primal
Definition: statistics.h:101
int iterationsCompProb
number of iterations of the complementary problem
Definition: statistics.h:119
Timer * transformTime
time for transforming LPs (included in solving time)
Definition: statistics.h:92
virtual void reset()=0
initialize timer, set timing accounts to zero.
int redProbStatus
status of the reduced problem
Definition: statistics.h:133
Real sumDualDegen
the sum of the rate of dual degeneracy at each iteration
Definition: statistics.h:126
Real luFactorizationTimeRational
time for factorizing bases matrices in rational precision
Definition: statistics.h:98
Real totalBoundViol
the sum of the bound violations in the original problem using the red prob sol
Definition: statistics.h:129
int rationalReconstructions
number of rational reconstructions performed
Definition: statistics.h:108
int pivotRefinements
number of refinement steps until final basis is reached
Definition: statistics.h:111
int numRedProbRows
number of rows in the reduced problem
Definition: statistics.h:120
int degenPivotsPrimal
number of primal degenerate pivots
Definition: statistics.h:122