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-2015 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 #ifndef SOPLEX_LEGACY
17 #include <iostream>
18 #include <assert.h>
19 
20 #include "statistics.h"
21 #include "timerfactory.h"
22 
23 namespace soplex
24 {
25 
26  /// default constructor
28  {
29  timerType = ttype;
38  clearAllData();
39  }
40 
41  /// copy constructor
43  {
44  timerType = base.timerType;
45  readingTime = TimerFactory::createTimer(timerType);
46  solvingTime = TimerFactory::createTimer(timerType);
47  preprocessingTime = TimerFactory::createTimer(timerType);
48  simplexTime = TimerFactory::createTimer(timerType);
49  syncTime = TimerFactory::createTimer(timerType);
50  transformTime = TimerFactory::createTimer(timerType);
51  rationalTime = TimerFactory::createTimer(timerType);
52  reconstructionTime = TimerFactory::createTimer(timerType);
53  clearAllData();
54  }
55 
56  /// assignment operator
58  {
59  *readingTime = *(rhs.readingTime);
60  *solvingTime = *(rhs.solvingTime);
61  *preprocessingTime = *(rhs.preprocessingTime);
62  *simplexTime = *(rhs.simplexTime);
63  *syncTime = *(rhs.syncTime);
64  *transformTime = *(rhs.transformTime);
65  *rationalTime = *(rhs.rationalTime);
66  *reconstructionTime = *(rhs.reconstructionTime);
67  timerType = rhs.timerType;
68  luFactorizationTimeReal = rhs.luFactorizationTimeReal;
69  luSolveTimeReal = rhs.luSolveTimeReal;
70  luFactorizationTimeRational = rhs.luFactorizationTimeRational;
71  luSolveTimeRational = rhs.luSolveTimeRational;
72  iterations = rhs.iterations;
73  iterationsPrimal = rhs.iterationsPrimal;
74  iterationsFromBasis = rhs.iterationsFromBasis;
75  boundflips = rhs.boundflips;
76  luFactorizationsReal = rhs.luFactorizationsReal;
77  luSolvesReal = rhs.luSolvesReal;
78  luFactorizationsRational = rhs.luFactorizationsRational;
79  rationalReconstructions = rhs.rationalReconstructions;
80  refinements = rhs.refinements;
81  stallRefinements = rhs.stallRefinements;
82  pivotRefinements = rhs.pivotRefinements;
83  feasRefinements = rhs.feasRefinements;
84  unbdRefinements = rhs.unbdRefinements;
85 
86  return *this;
87  }
88 
89  /// clears all statistics
91  {
92  readingTime->reset();
93  clearSolvingData();
94  }
95 
96  /// clears statistics on solving process
98  {
99  solvingTime->reset();
100  preprocessingTime->reset();
101  simplexTime->reset();
102  syncTime->reset();
103  transformTime->reset();
104  rationalTime->reset();
105  reconstructionTime->reset();
106  luFactorizationTimeReal = 0.0;
107  luSolveTimeReal = 0.0;
108  luFactorizationTimeRational = 0.0;
109  luSolveTimeRational = 0.0;
110  iterations = 0;
111  iterationsPrimal = 0;
112  iterationsFromBasis = 0;
113  boundflips = 0;
114  luFactorizationsReal = 0;
115  luSolvesReal = 0;
116  luFactorizationsRational = 0;
117  rationalReconstructions = 0;
118  refinements = 0;
119  stallRefinements = 0;
120  pivotRefinements = 0;
121  feasRefinements = 0;
122  unbdRefinements = 0;
123  }
124 
125  /// prints statistics
126  void SoPlex::Statistics::print(std::ostream& os)
127  {
128  Real solTime = solvingTime->time();
129  Real totTime = readingTime->time() + solTime;
130  Real otherTime = solTime - syncTime->time() - transformTime->time() - preprocessingTime->time() - simplexTime->time() - rationalTime->time();
131 
132  os << std::fixed << std::setprecision(2);
133 
134  os << "Total time : " << totTime << "\n"
135  << " Reading : " << readingTime->time() << "\n"
136  << " Solving : " << solTime << "\n"
137  << " Preprocessing : " << preprocessingTime->time();
138  if( solTime > 0 )
139  os << " (" << 100 * (preprocessingTime->time() / solTime) << "% of solving time)";
140  os << "\n Simplex : " << simplexTime->time();
141  if( solTime > 0 )
142  os << " (" << 100 * (simplexTime->time() / solTime) << "% of solving time)";
143  os << "\n Synchronization : " << syncTime->time();
144  if( solTime > 0 )
145  os << " (" << 100 * (syncTime->time() / solTime) << "% of solving time)";
146  os << "\n Transformation : " << transformTime->time();
147  if( solTime > 0 )
148  os << " (" << 100*transformTime->time() / solTime << "% of solving time)";
149  os << "\n Rational : " << rationalTime->time();
150  if( solTime > 0 )
151  os << " (" << 100*rationalTime->time() / solTime << "% of solving time)";
152  os << "\n Other : " << otherTime;
153  if( solTime > 0 )
154  os << " (" << 100*otherTime / solTime << "% of solving time)";
155 
156  os << "\nRefinements : " << refinements << "\n"
157  << " Stalling : " << stallRefinements << "\n"
158  << " Pivoting : " << pivotRefinements << "\n"
159  << " Feasibility : " << feasRefinements << "\n"
160  << " Unboundedness : " << unbdRefinements << "\n";
161 
162  os << "Iterations : " << iterations << "\n"
163  << " From scratch : " << iterations - iterationsFromBasis;
164  if( iterations > 0 )
165  os << " (" << 100*double((iterations - iterationsFromBasis))/double(iterations) << "%)";
166  os << "\n From basis : " << iterationsFromBasis;
167  if( iterations > 0 )
168  os << " (" << 100*double(iterationsFromBasis)/double(iterations) << "%)";
169  os << "\n Primal : " << iterationsPrimal;
170  if( iterations > 0 )
171  os << " (" << 100*double(iterationsPrimal)/double(iterations) << "%)";
172  os << "\n Dual : " << iterations - iterationsPrimal;
173  if( iterations > 0 )
174  os << " (" << 100*double((iterations - iterationsPrimal))/double(iterations) << "%)";
175  os << "\n Bound flips : " << boundflips;
176 
177  os << "\nLU factorizations : " << luFactorizationsReal << "\n"
178  << " Factor. frequency : ";
179  if( luFactorizationsReal > 0 )
180  os << double(iterations) / double(luFactorizationsReal) << " iterations per factorization\n";
181  else
182  os << "-\n";
183  os << " Factor. time : " << luFactorizationTimeReal << "\n";
184 
185  os << "LU solves : " << luSolvesReal << "\n"
186  << " Solve frequency : ";
187  if( luSolvesReal > 0 )
188  os << double(luSolvesReal) / double(iterations) << " solves per iteration\n";
189  else
190  os << "-\n";
191  os << " Solve time : " << luSolveTimeReal << "\n";
192 
193  os << "Rat. factorizations : " << luFactorizationsRational << "\n"
194  << " Rat. factor. time : " << luFactorizationTimeRational << "\n"
195  << " Rat. solve time : " << luSolveTimeRational << "\n";
196 
197  os << "Rat. reconstructions: " << rationalReconstructions << "\n"
198  << " Rat. rec. time : " << reconstructionTime->time() << "\n";
199  }
200 } // namespace soplex
201 #endif