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 ComputeBisimulation 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 ComputeBisimulation
41  // and will hold the coarsest quasi-congruence on genOrig, where each equivalence class is represented by a state
42  Generator genPart;
43 
44  // call the function ComputeBisimulation which computes the coarses quasi-congruence
45  ComputeBisimulation(genOrig, mapStateToPartition, genPart);
46 
47  // Write the resulting generator that holds the quasi-congruence to console
48  std::cout << "#########################################\n";
49  std::cout << "# generator holding the quasi-congruence\n";
50  std::cout << "#########################################\n";
51  genPart.DWrite();
52  // Write the resulting generator to file output
53  genPart.Write("./results/ex_bisim/genPart.gen");
54  // output the map from states in the original generator to equivalence classes (states in genPart)
55  std::map<Idx,Idx>::const_iterator mIt, mEndIt;
56  mIt = mapStateToPartition.begin();
57  mEndIt = mapStateToPartition.end();
58  std::cout << "##################################################\n";
59  std::cout << "# map from original states to equivalence classes\n";
60  for( ; mIt != mEndIt; mIt++){
61  std::cout << "state: " << mIt->first << " class: " << mIt->second << "\n";
62  }
63  std::cout << "##################################################\n";
64 
65  return 0;
66 }
void DWrite(const Type *pContext=0) const
Write configuration data to console, debugging format.
Definition: cfl_types.cpp:225
void Write(const Type *pContext=0) const
Write configuration data to console.
Definition: cfl_types.cpp:139
Base class of all FAUDES generators.
void ComputeBisimulation(const Generator &rGenOrig, map< Idx, Idx > &rMapStateToPartition)
Computation of the coarsest bisimulation relation for a specified generator.
Includes all libFAUDES headers, incl plugings
libFAUDES resides within the namespace faudes.
int main(int argc, char *argv[])
Definition: op_ex_bisim.cpp:26

libFAUDES 2.32f --- 2024.12.22 --- c++ api documentaion by doxygen