spot  2.16
mc.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) by the Spot authors, see the AUTHORS file for details.
3 //
4 // This file is part of Spot, a model checking library.
5 //
6 // Spot is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // Spot is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 #pragma once
20 
21 #include <iostream>
22 #include <stdexcept>
23 #include <string>
24 #include <vector>
25 #include <utility>
26 
27 #include <spot/misc/common.hh>
28 
34 
35 namespace spot
36 {
38  enum class SPOT_API mc_algorithm
39  {
40  BLOEMEN_EC,
41  BLOEMEN_SCC,
42  CNDFS,
43  DEADLOCK,
44  REACHABILITY,
45  SWARMING,
46  };
47 
49  enum class SPOT_API mc_rvalue
50  {
51  DEADLOCK,
52  EMPTY,
53  FAILURE,
54  NO_DEADLOCK,
55  NOT_EMPTY,
56  SUCCESS,
57  };
58 
61  struct SPOT_API ec_stats
62  {
63  std::vector<std::string> name;
64  std::vector<unsigned> walltime;
65  std::vector<unsigned> states;
66  std::vector<unsigned> transitions;
67  std::vector<int> sccs;
68  std::vector<mc_rvalue> value;
69  std::vector<bool> finisher;
70  std::string trace;
71  };
72 
74  SPOT_API std::ostream& operator<<(std::ostream& os, const mc_algorithm& ma)
75  {
76  switch (ma)
77  {
79  os << "bloemen_ec"; break;
81  os << "bloemen_scc"; break;
83  os << "cndfs"; break;
85  os << "deadlock"; break;
87  os << "reachability"; break;
89  os << "swarming"; break;
90  }
91  return os;
92  }
93 
95  SPOT_API std::ostream& operator<<(std::ostream& os, const mc_rvalue& mr)
96  {
97  switch (mr)
98  {
100  os << "deadlock"; break;
101  case mc_rvalue::EMPTY:
102  os << "empty"; break;
103  case mc_rvalue::FAILURE:
104  os << "failure"; break;
106  os << "no_deadlock"; break;
108  os << "not_empty"; break;
109  case mc_rvalue::SUCCESS:
110  os << "success"; break;
111  }
112  return os;
113  }
114 
116  SPOT_API std::ostream& operator<<(std::ostream& os, const ec_stats& es)
117  {
118  for (unsigned i = 0; i < es.name.size(); ++i)
119  {
120  os << "---- Thread number:\t" << i << '\n'
121  << " - Algorithm:\t\t" << es.name[i] << '\n'
122  << " - Walltime (ms):\t" << es.walltime[i] <<'\n'
123  << " - States:\t\t" << es.states[i] << '\n'
124  << " - Transitions:\t" << es.transitions[i] << '\n'
125  << " - Result:\t\t" << es.value[i] << '\n'
126  << " - SCCs:\t\t" << es.sccs[i] << '\n';
127 
128  os << "CSV: tid,algorithm,walltime,states,transitions,"
129  "sccs,result,finisher\n"
130  << "@th_" << i << ',' << es.name[i] << ',' << es.walltime[i] << ','
131  << es.states[i] << ',' << es.transitions[i] << ','
132  << es.sccs[i] << ',' << es.value[i]
133  << ',' << es.finisher[i] << "\n\n";
134  }
135  return os;
136  }
137 
140  SPOT_API const mc_rvalue operator|(const mc_rvalue& lhs, const mc_rvalue& rhs)
141  {
142  // Handle Deadlocks
143  if (lhs == mc_rvalue::DEADLOCK && rhs == mc_rvalue::DEADLOCK)
144  return mc_rvalue::DEADLOCK;
145  if (lhs == mc_rvalue::NO_DEADLOCK && rhs == mc_rvalue::NO_DEADLOCK)
146  return mc_rvalue::NO_DEADLOCK;
147  if ((lhs == mc_rvalue::DEADLOCK && rhs == mc_rvalue::NO_DEADLOCK) ||
148  (lhs == mc_rvalue::NO_DEADLOCK && rhs == mc_rvalue::DEADLOCK))
149  return mc_rvalue::DEADLOCK;
150 
151  // Handle Emptiness
152  if (lhs == mc_rvalue::EMPTY && rhs == mc_rvalue::EMPTY)
153  return mc_rvalue::EMPTY;
154  if (lhs == mc_rvalue::NOT_EMPTY && rhs == mc_rvalue::NOT_EMPTY)
155  return mc_rvalue::NOT_EMPTY;
156  if ((lhs == mc_rvalue::EMPTY && rhs == mc_rvalue::NOT_EMPTY) ||
157  (lhs == mc_rvalue::NOT_EMPTY && rhs == mc_rvalue::EMPTY))
158  return mc_rvalue::EMPTY;
159 
160  // Handle Failure / Success
161  if (lhs == mc_rvalue::FAILURE && rhs == mc_rvalue::FAILURE)
162  return mc_rvalue::FAILURE;
163  if (lhs == mc_rvalue::SUCCESS && rhs == mc_rvalue::SUCCESS)
164  return mc_rvalue::SUCCESS;
165  if ((lhs == mc_rvalue::FAILURE && rhs == mc_rvalue::SUCCESS) ||
166  (lhs == mc_rvalue::SUCCESS && rhs == mc_rvalue::FAILURE))
167  return mc_rvalue::FAILURE;
168 
169  throw std::runtime_error("Unable to compare these elements!");
170  }
171 }
Definition: automata.hh:26
mc_algorithm
The list of parallel model-checking algorithms available.
Definition: mc.hh:39
@ CNDFS
Evangelista.12.atva emptiness check.
@ REACHABILITY
Only perform a reachability algorithm.
@ SWARMING
Holzmann.11.ieee applied to renault.13.lpar.
@ DEADLOCK
Check whether there is a deadlock.
@ BLOEMEN_SCC
Bloemen.16.ppopp SCC computation.
@ BLOEMEN_EC
Bloemen.16.hvc emptiness check.
mc_rvalue
Return value of a parallel model-checking algorithm.
Definition: mc.hh:50
@ NOT_EMPTY
The product is not empty.
@ NO_DEADLOCK
No deadlock has been found.
@ FAILURE
The algorithm finished abnormally.
@ DEADLOCK
A deadlock has been found.
@ EMPTY
The product is empty.
@ SUCCESS
The algorithm finished normally.
std::ostream & operator<<(std::ostream &os, const mc_algorithm &ma)
Print an mc_algorithm value to a stream.
Definition: mc.hh:74
const mc_rvalue operator|(const mc_rvalue &lhs, const mc_rvalue &rhs)
This function helps to find the output value from a set of threads that may have different values.
Definition: mc.hh:140
This structure contains, for each thread, the collected information during the traversal.
Definition: mc.hh:62
std::vector< mc_rvalue > value
The return status.
Definition: mc.hh:68
std::vector< unsigned > walltime
Walltime for this thread in ms.
Definition: mc.hh:64
std::vector< bool > finisher
Is it the finisher thread?
Definition: mc.hh:69
std::vector< int > sccs
Number of SCCs or -1.
Definition: mc.hh:67
std::vector< unsigned > states
Number of states visited.
Definition: mc.hh:65
std::vector< unsigned > transitions
Number of transitions visited.
Definition: mc.hh:66
std::vector< std::string > name
The name of the algorithm used.
Definition: mc.hh:63
std::string trace
The output trace.
Definition: mc.hh:70

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Feb 27 2015 10:00:07 for spot by doxygen 1.9.1