1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 2 /* */ 3 /* This file is part of the class library */ 4 /* SoPlex --- the Sequential object-oriented simPlex. */ 5 /* */ 6 /* Copyright (c) 1996-2023 Zuse Institute Berlin (ZIB) */ 7 /* */ 8 /* Licensed under the Apache License, Version 2.0 (the "License"); */ 9 /* you may not use this file except in compliance with the License. */ 10 /* You may obtain a copy of the License at */ 11 /* */ 12 /* http://www.apache.org/licenses/LICENSE-2.0 */ 13 /* */ 14 /* Unless required by applicable law or agreed to in writing, software */ 15 /* distributed under the License is distributed on an "AS IS" BASIS, */ 16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ 17 /* See the License for the specific language governing permissions and */ 18 /* limitations under the License. */ 19 /* */ 20 /* You should have received a copy of the Apache-2.0 license */ 21 /* along with SoPlex; see the file LICENSE. If not email to soplex@zib.de. */ 22 /* */ 23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 24 25 /**@file statistics.h 26 * @brief Class for collecting statistical information 27 */ 28 #ifndef _STATISTICS_H_ 29 #define _STATISTICS_H_ 30 31 #include <iostream> 32 33 #include "soplex.h" 34 #include "soplex/timer.h" 35 36 namespace soplex 37 { 38 /**@class Statistics 39 * @brief Class for collecting statistical information 40 * @ingroup Algo 41 */ 42 template <class R> 43 class SoPlexBase<R>::Statistics 44 { 45 46 public: 47 48 49 ///@name Construction, resetting, printing 50 ///@{ 51 52 /// default constructor 53 Statistics(Timer::TYPE ttype = Timer::USER_TIME); 54 55 /// copy constructor 56 Statistics(const Statistics& base); 57 58 /// assignment operator 59 Statistics& operator=(const Statistics& rhs); 60 61 /// destructor 62 ~Statistics() 63 { 64 // we need to free all timers again (allocation happens in constructor) 65 readingTime->~Timer(); 66 solvingTime->~Timer(); 67 preprocessingTime->~Timer(); 68 simplexTime->~Timer(); 69 syncTime->~Timer(); 70 transformTime->~Timer(); 71 rationalTime->~Timer(); 72 initialPrecisionTime->~Timer(); 73 extendedPrecisionTime->~Timer(); 74 reconstructionTime->~Timer(); 75 boostingStepTime->~Timer(); 76 spx_free(readingTime); 77 spx_free(solvingTime); 78 spx_free(preprocessingTime); 79 spx_free(simplexTime); 80 spx_free(syncTime); 81 spx_free(transformTime); 82 spx_free(rationalTime); 83 spx_free(initialPrecisionTime); 84 spx_free(extendedPrecisionTime); 85 spx_free(reconstructionTime); 86 spx_free(boostingStepTime); 87 } 88 89 /// clears all statistics 90 void clearAllData(); 91 92 /// clears statistics on solving process 93 void clearSolvingData(); 94 95 /// prints statistics 96 void print(std::ostream& os); 97 98 99 ///@} 100 101 102 ///@name Data 103 ///@{ 104 105 Timer* readingTime; ///< reading time not included in solving time 106 Timer* solvingTime; ///< solving time 107 Timer* preprocessingTime; ///< preprocessing time 108 Timer* simplexTime; ///< simplex time 109 Timer* syncTime; ///< time for synchronization between real and rational LP (included in solving time) 110 Timer* transformTime; ///< time for transforming LPs (included in solving time) 111 Timer* rationalTime; ///< time for rational LP solving (included in solving time) 112 Timer* initialPrecisionTime; ///< solving time with initial precision (included in solving time) 113 Timer* extendedPrecisionTime; ///< solving time with extended precision (included in solving time) 114 Timer* reconstructionTime; ///< time for rational reconstructions 115 Timer* boostingStepTime; ///< time for the precision boosting step: boost, load LP, load basis, decrease tols (included in solving time) 116 Timer::TYPE timerType; ///< type of timer (user or wallclock) 117 118 Real multTimeSparse; ///< time for computing A*x exploiting sparsity (setupPupdate(), PRICE step) 119 Real multTimeFull; ///< time for computing A*x ignoring sparsity (setupPupdate(), PRICE step) 120 Real multTimeColwise; ///< time for computing A*x columnwise (setupPupdate(), PRICE step) 121 Real multTimeUnsetup; ///< time for computing A*x w/o sparsity information (setupPupdate(), PRICE step) 122 int multSparseCalls; ///< number of products A*x exploiting sparsity (setupPupdate(), PRICE step) 123 int multFullCalls; ///< number of products A*x ignoring sparsity (setupPupdate(), PRICE step) 124 int multColwiseCalls; ///< number of products A*x columnwise (setupPupdate(), PRICE step) 125 int multUnsetupCalls; ///< number of products A*x w/o sparsity information (setupPupdate(), PRICE step) 126 127 Real luFactorizationTimeReal; ///< time for factorizing bases matrices in real precision 128 Real luSolveTimeReal; ///< time for solving linear systems in real precision 129 Real luFactorizationTimeRational; ///< time for factorizing bases matrices in rational precision 130 Real luSolveTimeRational; ///< time for solving linear systems in rational precision 131 Real fpTime; ///< time for first floating-point LP solve 132 int iterations; ///< number of iterations/pivots 133 int iterationsPrimal; ///< number of iterations with Primal 134 int iterationsFromBasis; ///< number of iterations from Basis 135 int iterationsPolish; ///< number of iterations during solution polishing 136 int iterationsFP; ///< number of iterations/pivots in first floating-point solve 137 int boundflips; ///< number of dual bound flips 138 int boostedIterations; ///< number of iterations/pivots in extended precision 139 int boostedIterationsPrimal; ///< number of iterations with Primal 140 int boostedIterationsFromBasis; ///< number of iterations from Basis 141 int boostedIterationsPolish; ///< number of iterations during solution polishing 142 int boostedBoundflips; ///< number of dual bound flips 143 int luFactorizationsReal; ///< number of basis matrix factorizations in real precision 144 int luSolvesReal; ///< number of (forward and backward) solves with basis matrix in real precision 145 int luFactorizationsRational; ///< number of basis matrix factorizations in rational precision 146 int rationalReconstructions; ///< number of rational reconstructions performed 147 int refinements; ///< number of refinement steps 148 int stallRefinements; ///< number of refinement steps without pivots 149 int pivotRefinements; ///< number of refinement steps until final basis is reached 150 int feasRefinements; ///< number of refinement steps during infeasibility test 151 int unbdRefinements; ///< number of refinement steps during undboundedness test 152 int precBoosts; ///< number of precision boosts 153 int stallPrecBoosts; ///< number of precision boosts without pivots 154 int pivotPrecBoosts; ///< number of precision boosts until final basis is reached 155 int feasPrecBoosts; ///< number of precision boosts during infeasibility test 156 int unbdPrecBoosts; ///< number of precision boosts during undboundedness test 157 158 // Improved dual simplex statistics 159 int callsReducedProb; ///< number of times the reduced problem is solved. This includes the initial solve. 160 int iterationsInit; ///< number of iterations in the initial LP 161 int iterationsRedProb; ///< number of iterations of the reduced problem 162 int iterationsCompProb; ///< number of iterations of the complementary problem 163 int numRedProbRows; ///< number of rows in the reduced problem 164 int numRedProbCols; ///< number of columns in the reduced problem 165 int degenPivotsPrimal; ///< number of primal degenerate pivots 166 int degenPivotsDual; ///< number of dual degenerate pivots 167 int degenPivotCandPrimal; ///< number of pivoting candidates that will produce a degenerate step in the primal 168 int degenPivotCandDual; ///< number of pivoting candidates that will produce a degenerate step in the dual 169 R sumDualDegen; ///< the sum of the rate of dual degeneracy at each iteration 170 R sumPrimalDegen; ///< the sum of the rate of primal degeneracy at each iteration 171 R decompBasisCondNum; ///< the condition number for the basis used to perform the decomposition 172 R totalBoundViol; ///< the sum of the bound violations in the original problem using the red prob sol 173 R totalRowViol; ///< the sum of the row violations in the original problem using the red prob sol 174 R maxBoundViol; ///< the max bound violation in the original problem using the red prob sol 175 R maxRowViol; ///< the max row violations in the original problem using the red prob sol 176 int redProbStatus; ///< status of the reduced problem 177 int compProbStatus; ///< status of the complementary problem 178 R finalCompObj; ///< the final objective function of the complementary problem 179 180 // Numerics 181 R finalBasisCondition; ///< condition number estimate of the optimal basis matrix 182 183 ///@} 184 185 }; 186 } // namespace soplex 187 188 // For general templated files 189 #include "statistics.hpp" 190 191 #endif // _STATISTICS_H_ 192