00001 00002 // 00003 // Module : StableSetStatistics.cpp 00004 // Description : Statistics. 00005 // Author : Steffen Rebennack 00006 // Email : srebenac@ix.urz.uni-heidelberg.de; 00007 // steffen.rebennack@web.de 00008 // Copyright : (C) 2006 by the University of Heidelberg 00009 // Created on : Thu Apr 06 11:12:50 2006 00010 // Last modified by : - 00011 // Last modified on : - 00012 // Update count : 0 00013 // 00015 // 00016 // Date Name Changes/Extensions 00017 // ---- ---- ------------------ 00018 // 00020 00021 #include "StableSetStatistics.hh" 00022 00023 #include <iostream> 00024 using namespace std; 00025 00026 // ----------------------------------------------------------------------------- 00027 // --------------- M e t h o d s ( p u b l i c ) ------------------------------ 00028 // ----------------------------------------------------------------------------- 00029 00030 00031 // ----------------------------------------------------------------------------- 00032 // C o n s t r u c t o r 00033 // 00034 // Initialize all variables. 00035 // ----------------------------------------------------------------------------- 00036 StableSetStatistics::StableSetStatistics(): 00037 edgeInequalities(0), 00038 poolSeparationCuts(0), 00039 maxCliquesMemoryCuts(0), 00040 oddCyclesCuts(0), 00041 liftedOddCyclesCuts(0), 00042 exactCliquesCuts(0), 00043 cliqueHeuristicsCuts(0), 00044 edgeProjectionCuts(0), 00045 localCutCuts(0), 00046 modKCuts(0), 00047 dualBoundOfRoot(0), 00048 largeCuts(0), 00049 roundedSolutions(0), 00050 improvedSolutions(0), 00051 solutionFoundBy(-1), 00052 alphaRoot(-1) 00053 { 00054 } 00055 00056 00057 // ----------------------------------------------------------------------------- 00058 // D e s t r u c t o r 00059 // ----------------------------------------------------------------------------- 00060 StableSetStatistics::~StableSetStatistics() { 00061 } 00062 00063 00064 // ----------------------------------------------------------------------------- 00065 // e d g e I n e q u a l i t i e s C u t 00066 // ----------------------------------------------------------------------------- 00067 void StableSetStatistics::edgeInequalitiesCut(int num) { 00068 edgeInequalities = num < 0 ? edgeInequalities : edgeInequalities + num; 00069 } 00070 00071 00072 // ----------------------------------------------------------------------------- 00073 // p o o l S e p a r a t i o n C u t 00074 // ----------------------------------------------------------------------------- 00075 void StableSetStatistics::poolSeparationCut(int num) { 00076 poolSeparationCuts = num < 0 ? poolSeparationCuts : poolSeparationCuts +num; 00077 } 00078 00079 00080 // ----------------------------------------------------------------------------- 00081 // m a x C l i q u e s M e m o r y C u t 00082 // ----------------------------------------------------------------------------- 00083 void StableSetStatistics::maxCliquesMemoryCut(int num) { 00084 maxCliquesMemoryCuts = num < 0 ? maxCliquesMemoryCuts 00085 : maxCliquesMemoryCuts + num; 00086 } 00087 00088 00089 // ----------------------------------------------------------------------------- 00090 // o d d C y c l e s C u t 00091 // ----------------------------------------------------------------------------- 00092 void StableSetStatistics::oddCyclesCut(int num) { 00093 oddCyclesCuts = num < 0 ? oddCyclesCuts : oddCyclesCuts + num; 00094 } 00095 00096 00097 // ----------------------------------------------------------------------------- 00098 // l i f t e d O d d C y c l e s C u t 00099 // ----------------------------------------------------------------------------- 00100 void StableSetStatistics::liftedOddCyclesCut(int num) { 00101 liftedOddCyclesCuts = num < 0 ? liftedOddCyclesCuts 00102 : liftedOddCyclesCuts + num; 00103 } 00104 00105 00106 // ----------------------------------------------------------------------------- 00107 // e x a c t C l i q u e s C u t 00108 // ----------------------------------------------------------------------------- 00109 void StableSetStatistics::exactCliquesCut(int num) { 00110 exactCliquesCuts = num < 0 ? exactCliquesCuts : exactCliquesCuts + num; 00111 } 00112 00113 00114 // ----------------------------------------------------------------------------- 00115 // c l i q u e H e u r i s t i c s C u t 00116 // ----------------------------------------------------------------------------- 00117 void StableSetStatistics::cliqueHeuristicsCut(int num) { 00118 cliqueHeuristicsCuts = num < 0 ? cliqueHeuristicsCuts 00119 : cliqueHeuristicsCuts + num; 00120 } 00121 00122 00123 // ----------------------------------------------------------------------------- 00124 // e d g e P r o j e c t i o n C u t 00125 // ----------------------------------------------------------------------------- 00126 void StableSetStatistics::edgeProjectionCut(int num) { 00127 edgeProjectionCuts = num < 0 ? edgeProjectionCuts 00128 : edgeProjectionCuts + num; 00129 } 00130 00131 00132 // ----------------------------------------------------------------------------- 00133 // l o c a l C u t C u t 00134 // ----------------------------------------------------------------------------- 00135 void StableSetStatistics::localCutCut(int num) { 00136 localCutCuts = num < 0 ? localCutCuts : localCutCuts + num; 00137 } 00138 00139 // ----------------------------------------------------------------------------- 00140 // m o d K C u t 00141 // ----------------------------------------------------------------------------- 00142 void StableSetStatistics::modKCut(int num) { 00143 modKCuts = num < 0 ? modKCuts : modKCuts + num; 00144 } 00145 00146 // ----------------------------------------------------------------------------- 00147 // l a r g e C u t C u t 00148 // ----------------------------------------------------------------------------- 00149 void StableSetStatistics::largeCutCut(int num) { 00150 largeCuts = num < 0 ? largeCuts : largeCuts + num; 00151 } 00152 00153 00154 // ----------------------------------------------------------------------------- 00155 // s e t D u a l B o u n d 00156 // ----------------------------------------------------------------------------- 00157 void StableSetStatistics::setDualBound(double val) { 00158 dualBoundOfRoot = val; 00159 } 00160 00161 00162 // ----------------------------------------------------------------------------- 00163 // r o u n d i n g H e u r i s t i c s 00164 // ----------------------------------------------------------------------------- 00165 void StableSetStatistics::roundingHeuristics() { 00166 roundedSolutions++; 00167 } 00168 00169 00170 // ----------------------------------------------------------------------------- 00171 // i m p r o v e m e n t H e u r i s t i c s 00172 // ----------------------------------------------------------------------------- 00173 void StableSetStatistics::improvementHeuristics() { 00174 improvedSolutions++; 00175 } 00176 00177 00178 // ----------------------------------------------------------------------------- 00179 // s o l u t i o n F o u n d 00180 // ----------------------------------------------------------------------------- 00181 void StableSetStatistics::solutionFound(int index) { 00182 solutionFoundBy = index; 00183 } 00184 00185 00186 // ----------------------------------------------------------------------------- 00187 // s e t A l p h a R o o t 00188 // ----------------------------------------------------------------------------- 00189 void StableSetStatistics::setAlphaRoot(int alpha) { 00190 alphaRoot = alpha; 00191 } 00192 00193 00194 // ----------------------------------------------------------------------------- 00195 // g e t E d g e I n e q u a l i t i e s C u t 00196 // ----------------------------------------------------------------------------- 00197 int StableSetStatistics::getEdgeInequalitiesCut() const { 00198 return edgeInequalities; 00199 } 00200 00201 00202 // ----------------------------------------------------------------------------- 00203 // g e t P o o l S e p a r a t i o n C u t 00204 // ----------------------------------------------------------------------------- 00205 int StableSetStatistics::getPoolSeparationCut() const { 00206 return poolSeparationCuts; 00207 } 00208 00209 00210 // ----------------------------------------------------------------------------- 00211 // g e t M a x C l i q u e s M e m o r y C u t 00212 // ----------------------------------------------------------------------------- 00213 int StableSetStatistics::getMaxCliquesMemoryCut() const { 00214 return maxCliquesMemoryCuts; 00215 } 00216 00217 // ----------------------------------------------------------------------------- 00218 // g e t O d d C y c l e s C u t 00219 // ----------------------------------------------------------------------------- 00220 int StableSetStatistics::getOddCyclesCut() const { 00221 return oddCyclesCuts; 00222 } 00223 00224 00225 // ----------------------------------------------------------------------------- 00226 // g e t L i f t e d O d d C y c l e s C u t 00227 // ----------------------------------------------------------------------------- 00228 int StableSetStatistics::getLiftedOddCyclesCut() const { 00229 return liftedOddCyclesCuts; 00230 } 00231 00232 00233 // ----------------------------------------------------------------------------- 00234 // g e t E x a c t C l i q u e s C u t 00235 // ----------------------------------------------------------------------------- 00236 int StableSetStatistics::getExactCliquesCut() const { 00237 return exactCliquesCuts; 00238 } 00239 00240 00241 // ----------------------------------------------------------------------------- 00242 // g e t C l i q u e H e u r i s t i c s C u t 00243 // ----------------------------------------------------------------------------- 00244 int StableSetStatistics::getCliqueHeuristicsCut() const { 00245 return cliqueHeuristicsCuts; 00246 } 00247 00248 00249 // ----------------------------------------------------------------------------- 00250 // g e t E d g e P r o j e c t i o n C u t 00251 // ----------------------------------------------------------------------------- 00252 int StableSetStatistics::getEdgeProjectionCut() const { 00253 return edgeProjectionCuts; 00254 } 00255 00256 // ----------------------------------------------------------------------------- 00257 // g e t M o d K C u t 00258 // ----------------------------------------------------------------------------- 00259 int StableSetStatistics::getModKCut() const { 00260 return modKCuts; 00261 } 00262 00263 00264 // ----------------------------------------------------------------------------- 00265 // g e t L o c a l C u t C u t 00266 // ----------------------------------------------------------------------------- 00267 int StableSetStatistics::getLocalCutCut() const { 00268 return localCutCuts; 00269 } 00270 00271 00272 // ----------------------------------------------------------------------------- 00273 // g e t L a r g e C u t 00274 // ----------------------------------------------------------------------------- 00275 int StableSetStatistics::getLargeCut() const { 00276 return largeCuts; 00277 } 00278 00279 00280 // ----------------------------------------------------------------------------- 00281 // g e t R o u n d e d S o l u t i o n s 00282 // ----------------------------------------------------------------------------- 00283 int StableSetStatistics::getRoundedSolutions() const { 00284 return roundedSolutions; 00285 } 00286 00287 // ----------------------------------------------------------------------------- 00288 // g e t I m p r o v e d S o l u t i o n s 00289 // ----------------------------------------------------------------------------- 00290 int StableSetStatistics::getImprovedSolutions() const { 00291 return improvedSolutions; 00292 } 00293 00294 00295 // ----------------------------------------------------------------------------- 00296 // g e t A l p h a R o o t 00297 // ----------------------------------------------------------------------------- 00298 int StableSetStatistics::getAlphaRoot() const { 00299 return alphaRoot; 00300 } 00301 00302 00303 // ----------------------------------------------------------------------------- 00304 // g e t D u a l B o u n d 00305 // ----------------------------------------------------------------------------- 00306 double StableSetStatistics::getDualBound() const { 00307 return dualBoundOfRoot; 00308 } 00309 00310 00311 // ----------------------------------------------------------------------------- 00312 // s o l u t i o n W a s F o u n d B y 00313 // ----------------------------------------------------------------------------- 00314 char *StableSetStatistics::solutionWasFoundBy() const { 00315 00316 char *methods[] = {"integer solution", "rounding heuristics", 00317 "improvement heuristics", "preprocessing"}; 00318 00319 if (solutionFoundBy < 0 || solutionFoundBy > 3) { 00320 return "-1"; 00321 } 00322 00323 return methods[solutionFoundBy]; 00324 } 00325 00326