op_ex_bisim.cpp

Go to the documentation of this file.
00001 /** @file op_ex_bisim.cpp
00002 
00003 Tutorial, computation of the coarsest quasi-congruence
00004 
00005 This tutorial demonstrates the use of the Bisimulation class for computing the 
00006 coarsest quasi-congruence on a given automaton. The theoretical background for the
00007 provided methods can be found in
00008 J.-C. Fernandez, "An implementation of an efficient algorithm for
00009 bisimulation equivalence," Science of Computer Programming, vol. 13,
00010 pp. 219-236, 1990.
00011 
00012 @ingroup Tutorials
00013 
00014 @include op_ex_bisim.cpp
00015 */
00016 
00017 
00018 
00019 #include <stdio.h>
00020 #include <iostream>
00021 #include "libfaudes.h"
00022 
00023 using namespace faudes;
00024 
00025 
00026 int main(int argc, char* argv[]) {
00027 
00028   // read original generator from file input 
00029   Generator genOrig("data/ex_bisim/ex_bisim.gen");
00030   // Write the original generator to console
00031   std::cout << "#####################\n";
00032   std::cout << "# original generator \n";
00033   std::cout << "#####################\n";
00034   genOrig.DWrite();
00035   // create an empty map<Idx,Idx>
00036   // it is passed by reference to the fuction calcBisimulation and will map the index of 
00037   // each state (first Idx) to the index of its equivalence class (second Idx)
00038   std::map<Idx,Idx> mapStateToPartition;
00039   
00040   // create an empty Generator. It is passed by reference to the function calcBisimulation
00041   // and will hold the coarsest quasi-congruence on genOrig, where each equivalence class is represented by a state
00042   Generator genPart;
00043   
00044   // create an empty vecor<Idx>
00045   // this map is passed by reference to the function calcBisimulation and will hold the indices
00046   // of all equivalence classes
00047   std::vector<Idx> newPartitions;
00048   
00049   // call the function calcBisimulation which computes the coarses quasi-congruence
00050   calcBisimulation(genOrig, mapStateToPartition, genPart, newPartitions);
00051   
00052   // Write the resulting generator that holds the quasi-congruence to console
00053   std::cout << "#########################################\n";
00054   std::cout << "# generator holding the quasi-congruence\n";
00055   std::cout << "#########################################\n";
00056   genPart.DWrite();
00057   // Write the resulting generator to file output 
00058   genPart.Write("./results/ex_bisim/genPart.gen");
00059   // output the map from states in the original generator to equivalence classes (states in genPart)
00060   std::map<Idx,Idx>::const_iterator mIt, mEndIt;
00061   mIt = mapStateToPartition.begin();
00062   mEndIt = mapStateToPartition.end();
00063   std::cout << "##################################################\n";
00064   std::cout << "# map from original states to equivalence classes\n";
00065   for( ; mIt != mEndIt; mIt++){
00066     std::cout << "state: " << mIt->first << " class: " << mIt->second << "\n";
00067   }
00068   std::cout << "##################################################\n";
00069 
00070   return 0;
00071 }

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen