op_ex_bisim.cpp
Go to the documentation of this file.
1 /** @file op_ex_bisim.cpp
2 
3 Tutorial, computation of the coarsest quasi-congruence
4 
5 This tutorial demonstrates the use of the Bisimulation class for computing the
6 coarsest quasi-congruence on a given automaton. The theoretical background for the
7 provided methods can be found in
8 J.-C. Fernandez, "An implementation of an efficient algorithm for
9 bisimulation equivalence," Science of Computer Programming, vol. 13,
10 pp. 219-236, 1990.
11 
12 @ingroup Tutorials
13 
14 @include op_ex_bisim.cpp
15 */
16 
17 
18 
19 #include <stdio.h>
20 #include <iostream>
21 #include "libfaudes.h"
22 
23 using namespace faudes;
24 
25 
26 int main(int argc, char* argv[]) {
27 
28  // read original generator from file input
29  Generator genOrig("data/ex_bisim/ex_bisim.gen");
30  // Write the original generator to console
31  std::cout << "#####################\n";
32  std::cout << "# original generator \n";
33  std::cout << "#####################\n";
34  genOrig.DWrite();
35  // create an empty map<Idx,Idx>
36  // it is passed by reference to the fuction calcBisimulation and will map the index of
37  // each state (first Idx) to the index of its equivalence class (second Idx)
38  std::map<Idx,Idx> mapStateToPartition;
39 
40  // create an empty Generator. It is passed by reference to the function calcBisimulation
41  // and will hold the coarsest quasi-congruence on genOrig, where each equivalence class is represented by a state
42  Generator genPart;
43 
44  // create an empty vecor<Idx>
45  // this map is passed by reference to the function calcBisimulation and will hold the indices
46  // of all equivalence classes
47  std::vector<Idx> newPartitions;
48 
49  // call the function calcBisimulation which computes the coarses quasi-congruence
50  calcBisimulation(genOrig, mapStateToPartition, genPart, newPartitions);
51 
52  // Write the resulting generator that holds the quasi-congruence to console
53  std::cout << "#########################################\n";
54  std::cout << "# generator holding the quasi-congruence\n";
55  std::cout << "#########################################\n";
56  genPart.DWrite();
57  // Write the resulting generator to file output
58  genPart.Write("./results/ex_bisim/genPart.gen");
59  // output the map from states in the original generator to equivalence classes (states in genPart)
60  std::map<Idx,Idx>::const_iterator mIt, mEndIt;
61  mIt = mapStateToPartition.begin();
62  mEndIt = mapStateToPartition.end();
63  std::cout << "##################################################\n";
64  std::cout << "# map from original states to equivalence classes\n";
65  for( ; mIt != mEndIt; mIt++){
66  std::cout << "state: " << mIt->first << " class: " << mIt->second << "\n";
67  }
68  std::cout << "##################################################\n";
69 
70  return 0;
71 }

libFAUDES 2.24g --- 2014.09.15 --- c++ api documentaion by doxygen