spot  1.2.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
emptiness_stats.hh
1 // Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
2 // département Systèmes Répartis Coopératifs (SRC), Université Pierre
3 // et Marie Curie.
4 //
5 // This file is part of Spot, a model checking library.
6 //
7 // Spot is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Spot is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
20 #ifndef SPOT_TGBAALGOS_EMPTINESS_STATS_HH
21 # define SPOT_TGBAALGOS_EMPTINESS_STATS_HH
22 
23 #include <cassert>
24 #include <map>
25 #include "misc/ltstr.hh"
26 
27 namespace spot
28 {
29 
32 
34  {
35  virtual
37  {
38  }
39 
40  unsigned
41  get(const char* str) const
42  {
43  stats_map::const_iterator i = stats.find(str);
44  assert(i != stats.end());
45  return (this->*i->second)();
46  }
47 
48  typedef unsigned (unsigned_statistics::*unsigned_fun)() const;
49  typedef std::map<const char*, unsigned_fun, char_ptr_less_than> stats_map;
50  stats_map stats;
51  };
52 
59  {
60  public:
62  : set(false)
63  {
64  }
65 
67  : set(false)
68  {
69  seteq(o);
70  }
71 
72  bool
73  seteq(const unsigned_statistics& o)
74  {
75  if (!set)
76  {
77  unsigned_statistics::stats_map::const_iterator i;
78  for (i = o.stats.begin(); i != o.stats.end(); ++i)
79  stats[i->first] = (o.*i->second)();
80  set = true;
81  return true;
82  }
83  if (*this == o)
84  return true;
85  return false;
86  }
87 
88  typedef std::map<const char*, unsigned, char_ptr_less_than> stats_map;
89  stats_map stats;
90 
91 
92  bool
93  operator==(const unsigned_statistics_copy& o) const
94  {
95  stats_map::const_iterator i;
96  for (i = stats.begin(); i != stats.end(); ++i)
97  {
98  stats_map::const_iterator i2 = o.stats.find(i->first);
99  if (i2 == o.stats.end())
100  return false;
101  if (i->second != i2->second)
102  return false;
103  }
104  return true;
105  }
106 
107  bool
108  operator!=(const unsigned_statistics_copy& o) const
109  {
110  return !(*this == o);
111  }
112 
113  bool set;
114  };
115 
122  {
123  public :
124  ec_statistics()
125  : states_(0), transitions_(0), depth_(0), max_depth_(0)
126  {
127  stats["states"] =
128  static_cast<unsigned_statistics::unsigned_fun>(&ec_statistics::states);
129  stats["transitions"] =
130  static_cast<unsigned_statistics::unsigned_fun>
131  (&ec_statistics::transitions);
132  stats["max. depth"] =
133  static_cast<unsigned_statistics::unsigned_fun>
134  (&ec_statistics::max_depth);
135  }
136 
137  void
138  set_states(unsigned n)
139  {
140  states_ = n;
141  }
142 
143  void
144  inc_states()
145  {
146  ++states_;
147  }
148 
149  void
150  inc_transitions()
151  {
152  ++transitions_;
153  }
154 
155  void
156  inc_depth(unsigned n = 1)
157  {
158  depth_ += n;
159  if (depth_ > max_depth_)
160  max_depth_ = depth_;
161  }
162 
163  void
164  dec_depth(unsigned n = 1)
165  {
166  assert(depth_ >= n);
167  depth_ -= n;
168  }
169 
170  unsigned
171  states() const
172  {
173  return states_;
174  }
175 
176  unsigned
177  transitions() const
178  {
179  return transitions_;
180  }
181 
182  unsigned
183  max_depth() const
184  {
185  return max_depth_;
186  }
187 
188  unsigned
189  depth() const
190  {
191  return depth_;
192  }
193 
194  private :
195  unsigned states_;
196  unsigned transitions_;
197  unsigned depth_;
198  unsigned max_depth_;
199  };
200 
207  {
208  public:
210  : prefix_states_(0), cycle_states_(0)
211  {
212  stats["(non unique) states for prefix"] =
213  static_cast<unsigned_statistics::unsigned_fun>
214  (&ars_statistics::ars_prefix_states);
215  stats["(non unique) states for cycle"] =
216  static_cast<unsigned_statistics::unsigned_fun>
217  (&ars_statistics::ars_cycle_states);
218  }
219 
220  void
221  inc_ars_prefix_states()
222  {
223  ++prefix_states_;
224  }
225 
226  unsigned
227  ars_prefix_states() const
228  {
229  return prefix_states_;
230  }
231 
232  void
233  inc_ars_cycle_states()
234  {
235  ++cycle_states_;
236  }
237 
238  unsigned
239  ars_cycle_states() const
240  {
241  return cycle_states_;
242  }
243 
244  private:
245  unsigned prefix_states_;
246  unsigned cycle_states_;
247  };
248 
255  {
256  public:
258  {
259  stats["search space states"] =
260  static_cast<unsigned_statistics::unsigned_fun>
262  }
263 
264  virtual
265  ~acss_statistics()
266  {
267  }
268 
270  virtual unsigned acss_states() const = 0;
271  };
272 
273 
275 }
276 
277 #endif // SPOT_TGBAALGOS_EMPTINESS_STATS_HH

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Sat Dec 6 2014 12:28:44 for spot by doxygen 1.8.4