libFAUDES

Sections

Index

cfl_parallel.h

Go to the documentation of this file.
00001 /** @file cfl_parallel.h parallel composition */
00002 
00003 /* FAU Discrete Event Systems Library (libfaudes)
00004 
00005    Copyright (C) 2006  Bernd Opitz
00006    Exclusive copyright is granted to Klaus Schmidt
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Lesser General Public
00010    License as published by the Free Software Foundation; either
00011    version 2.1 of the License, or (at your option) any later version.
00012 
00013    This library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Lesser General Public License for more details.
00017 
00018    You should have received a copy of the GNU Lesser General Public
00019    License along with this library; if not, write to the Free Software
00020    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00021 
00022 
00023 #ifndef FAUDES_PARALLEL_H
00024 #define FAUDES_PARALLEL_H
00025 
00026 #include "cfl_agenerator.h"
00027 #include <stack>
00028 #include <map>
00029 #include <set>
00030 
00031 namespace faudes {
00032 
00033 
00034 /**
00035  * Parallel composition.
00036  *
00037  * Constructs the parallel composition of two generators, where shared events
00038  * are synchronised while non-shared events are executed independantly. 
00039  * The resulting generators alphabet is the union of the argument alphabets.
00040  * In this implementation, only accessible states are generated. 
00041  * On deterministic input this functions constructs a deterministic output.
00042  * See also Parallel(const vGenerator&,std::map< std::pair<Idx,Idx>, Idx>&,const vGenerator&, vGenerator&).
00043  *
00044  * @param rGen1
00045  *   First generator
00046  * @param rGen2
00047  *   Second generator
00048  * @param rResGen
00049  *   Reference to resulting parallel composition generator
00050  *
00051  * <h4>Example:</h4>
00052  * <table border=0> <tr> <td> <table>
00053  * <tr> <td> Generator G1 </td> <td> Generator G2 </td> </tr>
00054  * <tr>
00055  * <td> @image html tmp_parallel_g1.png </td>
00056  * <td> @image html tmp_parallel_g2.png </td>
00057  * </tr>
00058  * </table> </td> </tr> <tr> <td> <table width=100%>
00059  * <tr> <td> G1 || G2 </td> </tr>
00060  * <tr> <td> @image html tmp_parallel_g1g2.png </td> </tr>
00061  * </table> </td> </tr> </table>
00062  *
00063  * @ingroup GeneratorFunctions
00064  *
00065  */
00066 void Parallel(const vGenerator& rGen1, const vGenerator& rGen2, vGenerator& rResGen);
00067 
00068 
00069 /**
00070  * Parallel composition.
00071  *
00072  * See also Parallel(const vGenerator&, const vGenerator&, vGenerator&).
00073  * This version tries to be transparent on event attributes: if
00074  * argument attributes match and if the result can take the respective
00075  * attributes, then they are copied; it is considered an error if 
00076  * argument attributes do not match.
00077  *
00078  * @param rGen1
00079  *   First generator
00080  * @param rGen2
00081  *   Second generator
00082  * @param rResGen
00083  *   Reference to resulting composition generator
00084  *
00085  * @ingroup GeneratorFunctions
00086  */
00087 void aParallel(const vGenerator& rGen1, const vGenerator& rGen2, vGenerator& rResGen);
00088 
00089 /**
00090  * Parallel composition.
00091  *
00092  * See also aParallel(const vGenerator&, const vGenerator&, vGenerator&).
00093  * This version takes a vector of generators as argument to perform
00094  * a synchronous composition of multiple generators. The implementation
00095  * calls the std aParallel multiple times, future implementations may
00096  * explore the overall reachable state set.
00097  *
00098  * @param rGenVec
00099  *   Vector of input generators
00100  * @param rResGen
00101  *   Reference to resulting composition generator
00102  *
00103  */
00104 void aParallel(const GeneratorVector& rGenVec, vGenerator& rResGen);
00105 
00106 
00107 /**
00108  * Parallel composition.
00109  *
00110  * See Parallel(const vGenerator&, const vGenerator&, vGenerator&).
00111  * This version fills given a reverse composition map to map pairs of old states
00112  * to new states.
00113  *
00114  * @param rGen1
00115  *   First generator
00116  * @param rGen2
00117  *   Second generator
00118  * @param rReverseCompositionMap
00119  *   Reverse composition map (map< pair<Idx,Idx>, Idx>)
00120  * @param rResGen
00121  *   Reference to resulting parallel composition generator
00122  */
00123 void Parallel(
00124     const vGenerator& rGen1, const vGenerator& rGen2,
00125     std::map< std::pair<Idx,Idx>, Idx>& rReverseCompositionMap, 
00126     vGenerator& rResGen);
00127 
00128 
00129 /**
00130  * Parallel composition.
00131  *
00132  * See Parallel(const vGenerator&, const vGenerator&, vGenerator&).
00133  * This version fills given a reverse composition map to map pairs of old states
00134  * to new states. It also returns the sets of states marked w.r.t. the
00135  * argument generators.
00136  *
00137  * @param rGen1
00138  *   First generator
00139  * @param rGen2
00140  *   Second generator
00141  * @param rReverseCompositionMap
00142  *   Reverse composition map (map< pair<Idx,Idx>, Idx>)
00143  * @param rMark2
00144  *   States maked in first generator
00145  * @param rMark1
00146  *   States maked in second generator
00147  * @param rResGen
00148  *   Reference to resulting parallel composition generator
00149  */
00150 void Parallel(
00151     const vGenerator& rGen1, const vGenerator& rGen2,
00152     std::map< std::pair<Idx,Idx>, Idx>& rReverseCompositionMap, 
00153     StateSet& rMark1,
00154     StateSet& rMark2,
00155     vGenerator& rResGen);
00156 
00157 
00158 /**
00159  * Product composition.
00160  * 
00161  * The product composition executes shared events only. The resulting
00162  * generators alphabet is the interscetion of the argument alphabets.
00163  * In this implementation, only accessible states are generated. 
00164  * Assumes deterministic input generators, result is deterministic.
00165  *
00166  * @param rGen1
00167  *   First generator
00168  * @param rGen2
00169  *   Second generator
00170  * @param rResGen
00171  *   Reference to resulting product composition generator
00172  *
00173  * @ingroup GeneratorFunctions
00174  */
00175 void Product(const vGenerator& rGen1, const vGenerator& rGen2, vGenerator& rResGen);
00176 
00177 
00178 /**
00179  * Product composition.
00180  * 
00181  * See Product(const vGenerator&, const vGenerator&, vGenerator&).
00182  * This version fills given reverse composition map to map pairs of old states
00183  * to new states.
00184  *
00185  * @param rGen1
00186  *   First generator
00187  * @param rGen2
00188  *   Second generator
00189  * @param rReverseCompositionMap
00190  *   Reverse composition map (map< pair<Idx,Idx>, Idx>)
00191  * @param rResGen
00192  *   Reference to resulting product composition generator
00193  */
00194 void Product(
00195     const vGenerator& rGen1, const vGenerator& rGen2,
00196     std::map< std::pair<Idx,Idx>, Idx>& rReverseCompositionMap, 
00197     vGenerator& rResGen);
00198 
00199 
00200 /**
00201  * Product composition.
00202  * 
00203  * See Product(const vGenerator&, const vGenerator&, vGenerator&).
00204  * This version fills given reverse composition map to map pairs of old states
00205  * to new states. It also returns the sets of states marked w.r.t. the
00206  * argument generators.
00207  *
00208  * @param rGen1
00209  *   First generator
00210  * @param rGen2
00211  *   Second generator
00212  * @param rReverseCompositionMap
00213  *   Reverse composition map (map< pair<Idx,Idx>, Idx>)
00214  * @param rMark2
00215  *   States maked in first generator
00216  * @param rMark1
00217  *   States maked in second generator
00218  * @param rResGen
00219  *   Reference to resulting product composition generator
00220  */
00221 void Product(
00222     const vGenerator& rGen1, const vGenerator& rGen2,
00223     std::map< std::pair<Idx,Idx>, Idx>& rReverseCompositionMap, 
00224     StateSet& rMark1,
00225     StateSet& rMark2,
00226     vGenerator& rResGen);
00227 
00228 
00229 /**
00230  * Product composition.
00231  *
00232  * See also Product(const vGenerator&, const vGenerator&, vGenerator&).
00233  * This version tries to be transparent on event attributes: if
00234  * argument attributes match and if the result can take the respective
00235  * attributes, then they are copied; it is considered an error if 
00236  * argument attributes do not match.
00237  *
00238  * @param rGen1
00239  *   First generator
00240  * @param rGen2
00241  *   Second generator
00242  * @param rResGen
00243  *   Reference to resulting product composition generator
00244  *
00245  * @ingroup GeneratorFunctions
00246  */
00247 void aProduct(const vGenerator& rGen1, const vGenerator& rGen2, vGenerator& rResGen);
00248 
00249 
00250 /**
00251  * Helper: uses reverse composition map to track state names
00252  * in a paralell composition. Purely cosmetic.
00253  *
00254  * @param rGen1
00255  *   First generator
00256  * @param rGen2
00257  *   Second generator
00258  * @param rReverseCompositionMap
00259  *   Reverse composition map (map< pair<Idx,Idx>, Idx>)
00260  * @param rGen12
00261  *   Reference to resulting parallel composition generator
00262  */
00263 void SetComposedStateNames(
00264     const vGenerator& rGen1, const vGenerator& rGen2,
00265     const std::map< std::pair<Idx,Idx>, Idx>& rReverseCompositionMap, 
00266     vGenerator& rGen12);
00267 
00268 /**
00269  * Helper: extract composition map from reverse composition map.
00270  * The reverse composition map is an optional return value of functions
00271  * that operate on the product state space of two component generators, e.g. Parallel. 
00272  * It maps pairs of component state indices to the correponding index in the product set. 
00273  * Occasionally, one requires a map from the product space to to one of the component indicees.
00274  * This function extracts the latter from the reverse composition map. There are two versions,
00275  * one for each component.
00276  * 
00277  * @param rReverseCompositionMap
00278  *  provided map from pairs of component states to states in the product space
00279  * @param rCompositionMap
00280  *  resulting map from the product space to states from the first compoent
00281  * 
00282  */
00283 void CompositionMap1(
00284   const std::map< std::pair<Idx,Idx>, Idx>& rReverseCompositionMap, 
00285   std::map<Idx,Idx>& rCompositionMap);
00286 
00287 
00288 /**
00289  * Helper: extract composition map from reverse composition map.
00290  * See also CompositionMap1.
00291  * 
00292  * @param rReverseCompositionMap
00293  *  provided map from pairs of component states to states in the product space
00294  * @param rCompositionMap
00295  *  resulting map from the product space to states from the second component
00296  * 
00297  */
00298 void CompositionMap2(
00299   const std::map< std::pair<Idx,Idx>, Idx>& rReverseCompositionMap, 
00300   std::map<Idx,Idx>& rCompositionMap);
00301 
00302 
00303 } // namespace faudes
00304 
00305 #endif 
00306 

libFAUDES 2.18b --- 2010-12-17 --- c++ source docu by doxygen 1.6.3