op_bisimulation.hGo to the documentation of this file.00001 /** @file op_bisimulation.h 00002 00003 Methods to compute bisimulations on dynamic systems (represented 00004 by a finite automaton). 00005 The relevant algorithms are described in 00006 J.-C. Fernandez, "An implementation of an efficient algorithm for 00007 bisimulation equivalence", Science of Computer Programming, vol. 13, 00008 pp. 219-236, 1990. 00009 The class bisimulation supports these methods. 00010 */ 00011 00012 /* FAU Discrete Event Systems Library (libfaudes) 00013 00014 Copyright (C) 2006 Bernd Opitz 00015 Exclusive copyright is granted to Klaus Schmidt 00016 00017 This library is free software; you can redistribute it and/or 00018 modify it under the terms of the GNU Lesser General Public 00019 License as published by the Free Software Foundation; either 00020 version 2.1 of the License, or (at your option) any later version. 00021 00022 This library is distributed in the hope that it will be useful, 00023 but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00025 Lesser General Public License for more details. 00026 00027 You should have received a copy of the GNU Lesser General Public 00028 License along with this library; if not, write to the Free Software 00029 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 00030 00031 #include "corefaudes.h" 00032 #include "op_partition.h" 00033 #include "op_debug.h" 00034 #include <vector> 00035 #include <map> 00036 #include <string> 00037 #include <sstream> 00038 00039 #ifndef FAUDES_OP_BISIMULATION_H 00040 #define FAUDES_OP_BISIMULATION_H 00041 00042 00043 00044 namespace faudes { 00045 00046 /** 00047 * Computation of a bisimulation over a given generator. 00048 * This funcion reates an instance of the class Bisimulation and starts the computation 00049 * of the coarsest quasi-congruence on the given generator by calling the function Bisimulation::partition. 00050 * A generator representing the result of the computation is generated. 00051 * 00052 * @param rGenOrig 00053 * Original generator 00054 * @param rMapStateToPartition 00055 * Maps each state to its equivalence class 00056 * @param rGenPart 00057 * Quotient automaton representing the result of the computation. Each state corresponds to an 00058 * equivalence class 00059 * @param rNewPartitions 00060 * Holds the indices of all equivalence classes 00061 * 00062 * @ingroup ObserverPlugin 00063 */ 00064 void calcBisimulation(Generator& rGenOrig, std::map<Idx,Idx>& rMapStateToPartition, Generator& rGenPart, std::vector<Idx>& rNewPartitions); 00065 00066 /** 00067 * Computation of a bisimulation over a given generator. 00068 * This funcion reates an instance of the class Bisimulation and starts the computation 00069 * of the coarsest quasi-congruence on the given generator by calling the function Bisimulation::partition. 00070 * See J.-C. Fernandez, “An implementation of an efficient algorithm for bisimulation equivalence,” Science of Computer Programming, vol. 13, 00071 * pp. 219-236, 1990 for further details. 00072 * 00073 * @param rGenOrig 00074 * Original generator 00075 * @param rMapStateToPartition 00076 * Maps each state to its equivalence class 00077 * @param rNewPartitions 00078 * Holds the indices of all equivalence classes 00079 * 00080 * @ingroup ObserverPlugin 00081 */ 00082 void calcBisimulation(Generator& rGenOrig, std::map<Idx,Idx>& rMapStateToPartition, std::vector<Idx>& rNewPartitions); 00083 00084 /** 00085 * This class implements the algorithms needed for the computation of 00086 * the coarsest quasi-congruence (=Bisimulation) of a given generator. 00087 */ 00088 00089 class Bisimulation { 00090 00091 public: 00092 00093 /** 00094 * Contructor 00095 * 00096 * @param g 00097 * Original generator 00098 */ 00099 Bisimulation(Generator& g); 00100 00101 00102 /** 00103 * Write W-tree to console 00104 */ 00105 void writeW(void); 00106 00107 /** 00108 * Administration of the various steps of the computation of the coarsest quasi-congruence. An output 00109 * generator that represents the resulting quotient automaton is also provided. 00110 * 00111 * @param rMapStateToPartition 00112 * Maps each state to its equivalence class 00113 * @param rGenPart 00114 * Generator representing the result of the computation. Each state corresponds to an 00115 * euivalence class 00116 * @param rNewPartitions 00117 * Holds the indices of all equivalence classes 00118 */ 00119 void partition(std::map<Idx,Idx>& rMapStateToPartition, Generator& rGenPart, std::vector<Idx>& rNewPartitions); 00120 00121 00122 /** 00123 * Administration of the various steps of the computation of the coarsest quasi-congruence 00124 * 00125 * @param rMapStateToPartition 00126 * Maps each state to its equivalence class 00127 * @param rNewPartitions 00128 * Holds the indices of all equivalence classes 00129 */ 00130 void partition(std::map<Idx,Idx>& rMapStateToPartition, std::vector<Idx>& rNewPartitions); 00131 00132 /** 00133 * Write the current set of equivalence classes to console 00134 */ 00135 void writeRo(void); 00136 00137 private: 00138 00139 /** 00140 * Original Automaton 00141 */ 00142 Generator* gen; 00143 00144 /** 00145 * Compute info-maps for two cosets P1 and P2. The current partition is 00146 * stable with respect to their parent coset P. 00147 * 00148 * @param node 00149 * Coset whose states are examined 00150 * @param pSmallerPart 00151 * Child coset P1 of P with smaller number of states 00152 * @param pLargerPart 00153 * Child coset P2 of P with larger number of states 00154 * @param eIt 00155 * Event 00156 */ 00157 void computeInfoMaps(Partition& node, Partition* pSmallerPart, Partition* pLargerPart, EventSet::Iterator eIt); 00158 00159 /** 00160 * Compute info-maps for coset B 00161 * 00162 * @param B 00163 * Coset for which the info-map is computed 00164 * @param Bstates 00165 * Coset whose states are examined 00166 * @param eIt 00167 * iterator to an event in a EventSet 00168 * @param tb 00169 * StateSet containing all the states that have a *eIt-transition into the coset B 00170 */ 00171 void computeInfoMap(Partition& B, Partition& Bstates, EventSet::Iterator eIt, StateSet& tb); 00172 00173 /** 00174 * Check if a state has a eIt-transition into a coset denoted as node 00175 * 00176 * @param state 00177 * State to be examined 00178 * @param node 00179 * Coset 00180 * @param eIt 00181 * Event 00182 */ 00183 bool stateLeadsToPartition(Idx state, Partition& node, EventSet::Iterator eIt); 00184 00185 /** 00186 * W-tree. Contains all cosets ever created 00187 */ 00188 std::map<Idx, Partition> W; 00189 00190 /** 00191 * Counter to assign unique indices to the cosets 00192 */ 00193 Idx index; 00194 00195 /** 00196 * Contains the cosets of the current partition 00197 */ 00198 std::vector<Partition*> ro; 00199 00200 /** 00201 * TransSet of original generator sorted by EvX2X1 00202 */ 00203 TransSetEvX2X1 tset_evx2x1; 00204 00205 00206 /** 00207 * Refine current partition with respect to partition B 00208 * 00209 * @param B 00210 * Coset 00211 */ 00212 void partitionClass(Partition& B); 00213 00214 /** 00215 * Refine current partition with respect to partition B and make use of the fact that 00216 * the current partition is stable with respect to the parent coset of B. 00217 * 00218 * @param B 00219 * Coset 00220 */ 00221 void partitionSplitter (Partition& B); 00222 00223 00224 /** 00225 * Function needed for recursively plotting the W-tree to console. For debugging purpose 00226 * 00227 * @param node 00228 * Coset 00229 */ 00230 void writeNode(Partition& node); 00231 00232 /** 00233 * Holds the cosets that can possibly split cosets in ro 00234 */ 00235 std::set<Partition*> roDividers; 00236 }; 00237 00238 } 00239 00240 #endif 00241 libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen |