00001 // Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6), 00002 // département Systèmes Répartis Coopératifs (SRC), Université Pierre 00003 // et Marie Curie. 00004 // 00005 // This file is part of Spot, a model checking library. 00006 // 00007 // Spot is free software; you can redistribute it and/or modify it 00008 // under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation; either version 2 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // Spot is distributed in the hope that it will be useful, but WITHOUT 00013 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00014 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 00015 // License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with Spot; see the file COPYING. If not, write to the Free 00019 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00020 // 02111-1307, USA. 00021 00022 #ifndef SPOT_TGBAALGOS_EMPTINESS_STATS_HH 00023 # define SPOT_TGBAALGOS_EMPTINESS_STATS_HH 00024 00025 #include <cassert> 00026 #include <map> 00027 #include "misc/ltstr.hh" 00028 00029 namespace spot 00030 { 00031 00034 00035 struct unsigned_statistics 00036 { 00037 virtual 00038 ~unsigned_statistics() 00039 { 00040 } 00041 00042 unsigned 00043 get(const char* str) const 00044 { 00045 stats_map::const_iterator i = stats.find(str); 00046 assert(i != stats.end()); 00047 return (this->*i->second)(); 00048 } 00049 00050 typedef unsigned (unsigned_statistics::*unsigned_fun)() const; 00051 typedef std::map<const char*, unsigned_fun, char_ptr_less_than> stats_map; 00052 stats_map stats; 00053 }; 00054 00060 class ec_statistics: public unsigned_statistics 00061 { 00062 public : 00063 ec_statistics() 00064 : states_(0), transitions_(0), depth_(0), max_depth_(0) 00065 { 00066 stats["states"] = 00067 static_cast<unsigned_statistics::unsigned_fun>(&ec_statistics::states); 00068 stats["transitions"] = 00069 static_cast<unsigned_statistics::unsigned_fun> 00070 (&ec_statistics::transitions); 00071 stats["max. depth"] = 00072 static_cast<unsigned_statistics::unsigned_fun> 00073 (&ec_statistics::max_depth); 00074 } 00075 00076 void 00077 set_states(unsigned n) 00078 { 00079 states_ = n; 00080 } 00081 00082 void 00083 inc_states() 00084 { 00085 ++states_; 00086 } 00087 00088 void 00089 inc_transitions() 00090 { 00091 ++transitions_; 00092 } 00093 00094 void 00095 inc_depth(unsigned n = 1) 00096 { 00097 depth_ += n; 00098 if (depth_ > max_depth_) 00099 max_depth_ = depth_; 00100 } 00101 00102 void 00103 dec_depth(unsigned n = 1) 00104 { 00105 assert(depth_ >= n); 00106 depth_ -= n; 00107 } 00108 00109 unsigned 00110 states() const 00111 { 00112 return states_; 00113 } 00114 00115 unsigned 00116 transitions() const 00117 { 00118 return transitions_; 00119 } 00120 00121 unsigned 00122 max_depth() const 00123 { 00124 return max_depth_; 00125 } 00126 00127 unsigned 00128 depth() const 00129 { 00130 return depth_; 00131 } 00132 00133 private : 00134 unsigned states_; 00135 unsigned transitions_; 00136 unsigned depth_; 00137 unsigned max_depth_; 00138 }; 00139 00145 class ars_statistics: public unsigned_statistics 00146 { 00147 public: 00148 ars_statistics() 00149 : prefix_states_(0), cycle_states_(0) 00150 { 00151 stats["(non unique) states for prefix"] = 00152 static_cast<unsigned_statistics::unsigned_fun> 00153 (&ars_statistics::ars_prefix_states); 00154 stats["(non unique) states for cycle"] = 00155 static_cast<unsigned_statistics::unsigned_fun> 00156 (&ars_statistics::ars_cycle_states); 00157 } 00158 00159 void 00160 inc_ars_prefix_states() 00161 { 00162 ++prefix_states_; 00163 } 00164 00165 unsigned 00166 ars_prefix_states() const 00167 { 00168 return prefix_states_; 00169 } 00170 00171 void 00172 inc_ars_cycle_states() 00173 { 00174 ++cycle_states_; 00175 } 00176 00177 unsigned 00178 ars_cycle_states() const 00179 { 00180 return cycle_states_; 00181 } 00182 00183 private: 00184 unsigned prefix_states_; 00185 unsigned cycle_states_; 00186 }; 00187 00193 class acss_statistics: public ars_statistics 00194 { 00195 public: 00196 acss_statistics() 00197 { 00198 stats["search space states"] = 00199 static_cast<unsigned_statistics::unsigned_fun> 00200 (&acss_statistics::acss_states); 00201 } 00202 00203 virtual 00204 ~acss_statistics() 00205 { 00206 } 00207 00209 virtual unsigned acss_states() const = 0; 00210 }; 00211 00212 00214 } 00215 00216 #endif // SPOT_TGBAALGOS_EMPTINESS_STATS_HH