About
User Reference
C++ API
luafaudes
Developer
Links
libFAUDES online
libFAUDES

Sections

Index

cfl_project.h

Go to the documentation of this file.
00001 /** @file cfl_project.h projection and subset construction */
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_PROJECT_H
00024 
00025 #include "cfl_definitions.h"
00026 #include "cfl_agenerator.h"
00027 #include "cfl_localgen.h"
00028 #include "cfl_statemin.h"
00029 #include <stack>
00030 #include <map>
00031 #include <vector>
00032 #include <list>
00033 #include <utility>
00034 #include <limits>
00035 
00036 namespace faudes {
00037 
00038 
00039 /**
00040  * Make initial states unique.
00041  * If the argument generator
00042  * has precisely one initial state, this function does nothing. 
00043  * Else, this function introduces a new and unique initial state and relinks transitions
00044  * accordinly. If the argument generator used to have more than one initial state, this operation
00045  * may render the output nondeterministic. If the argument generator used to have no
00046  * initial state, the output generator will generate the empty string language as opposed to
00047  * the empty language. Otherwise, generated and marked languages are preserved. 
00048  *
00049  * Note: call this function followed by determine to convert the generator to a
00050  * deterministic generator with exactly one initial state.
00051  *
00052  *
00053  * @param rGen
00054  *   Reference to generator
00055  *
00056  * @ingroup GeneratorFunctions
00057  */
00058 void UniqueInit(Generator& rGen);
00059 
00060 /**
00061  * Make initial states unique.
00062  *
00063  * Convenience wrapper for UniqueInit(Generator&).
00064  *
00065  *
00066  * @param rGen
00067  *   Reference to generator
00068  * @param rResGen
00069  *   Reference to resulting generator
00070  *
00071  * @ingroup GeneratorFunctions
00072  */
00073 void UniqueInit(const Generator& rGen, Generator& rResGen);
00074 
00075 
00076 /**
00077  * Make generator deterministic.
00078  * Constructs a deterministic generator while preserving the generated and marked languages.
00079  * The implementation is based on the so called multiway merge variant of subset construction, 
00080  * in which the new state set becomes a subset of the power set og the given state set. It is of
00081  * exponential complexity. For details on the multiway merge algorithm see
00082  * "Ted Leslie, Efficient Approaches to Subset Construction, 
00083  *  Computer Science, University of Waterloo, 1995".
00084  * See also 
00085  * Deterministic(const Generator&,std::map<Idx,StateSet>&,Generator& rResGen) and
00086  * Deterministic(const Generator&,std::vector<StateSet>&,std::vector<Idx>&,Generator& rResGen).
00087  *
00088  * Technical detail: if the input has no initial state, then so has the output. In this
00089  * aspect this function does not match the test IsDeterministic(). See also UniqueInit().
00090  * 
00091  * @param rGen
00092  *   Reference to generator
00093  * @param rResGen
00094  *   Reference to resulting deterministic generator
00095  *
00096  * <h4>Example:</h4>
00097  * <table>
00098  * <tr> <td> Generator G </td> <td> Deterministic(G,Result) </td> </tr>
00099  * <tr>
00100  * <td> @image html tmp_deterministic_nondet.png </td>
00101  * <td> @image html tmp_deterministic_det.png </td>
00102  * </tr>
00103  * </table> 
00104  *
00105  * @ingroup GeneratorFunctions
00106  */
00107 void Deterministic(const Generator& rGen, Generator& rResGen);
00108 
00109 /**
00110  * Make generator deterministic.
00111  *
00112  * See also Deterministic(const Generator&, Generator&).
00113  * This version maintains event attributes provided they can be castes
00114  * to the result type.
00115  *
00116  * @param rGen
00117  *   Reference to generator
00118  * @param rResGen
00119  *   Reference to resulting deterministic generator
00120  *
00121  * @ingroup GeneratorFunctions
00122  */
00123 void aDeterministic(const Generator& rGen, Generator& rResGen);
00124 
00125 /**
00126  * Make generator deterministic.
00127  *
00128  * Constructs a deterministic generator while preserving the generated and marked languages.
00129  * See Deterministic(const Generator&,Generator& rResGen) for the intended
00130  * api. This version provides as a second parameter the resulting map from new states to
00131  * their respective original state set. It is used as a so called "entry state map" 
00132  * for deterministic projected generators.
00133  *
00134  * @param rGen
00135  *   Reference to generator
00136  * @param rEntryStatesMap
00137  *   Entry state map
00138  * @param rResGen
00139  *   Reference to resulting deterministic generator
00140  */
00141 void Deterministic(const Generator& rGen, std::map<Idx,StateSet>& rEntryStatesMap,
00142        Generator& rResGen);
00143 
00144 /**
00145  * Make generator deterministic. 
00146  *
00147  * Constructs a deterministic generator while preserving the generated and marked languages.
00148  * See Deterministic(const Generator&,Generator& rResGen) for the intended api. 
00149  * This version provides as second and third parameters the correspondence 
00150  * betwwen new states and the original state sets.
00151  * in vectors
00152  *
00153  * @param rGen
00154  *   Reference to generator
00155  * @param rPowerStates
00156  *   Vector that holds the power states
00157  * @param rDetStates 
00158  *   Vector that holds the corresponding deterministic states
00159  * @param rResGen
00160  *   Reference to resulting deterministic generator
00161  */
00162 void Deterministic(const Generator& rGen, std::vector<StateSet>& rPowerStates, 
00163        std::vector<Idx>& rDetStates, Generator& rResGen);
00164 
00165 /**
00166  * Language projection.
00167  *
00168  * Projects the generated and marked languages to another alphabet.
00169  * Transitions with events not in the projection alphabet are considered 
00170  * invisible and therefor acordingly relinked with a visible lable to the appropriate 
00171  * successor state. The projection alphabet is intended (but not required) to be 
00172  * a subset of the original alphabet. 
00173  * The results in general is nondeterministic. The input generator does not need to 
00174  * be deterministic. See Project(const Generator&,const EventSet&, Generator&) for
00175  * a version with deterministic result.
00176  *
00177  * @param rGen
00178  *   Reference to generator
00179  * @param rProjectAlphabet
00180  *   Projection alphabet
00181  *
00182  * @ingroup GeneratorFunctions
00183  */
00184 void ProjectNonDet(Generator& rGen, const EventSet& rProjectAlphabet);
00185 
00186 /**
00187  * Minimized deterministic projection. 
00188  *
00189  * Projects the generated and marked languages to a subalphabet of the original alphabet, 
00190  * and subsequently calls Deterministic and StateMin to construct a deterministic minimal
00191  * realisation of the result. The input generator does not need to be deterministic.
00192  *
00193  * @param rGen
00194  *   Reference to generator
00195  * @param rProjectAlphabet
00196  *   Projection alphabet
00197  * @param rResGen
00198  *   Reference to resulting deterministic generator
00199  *
00200  * <h4>Example:</h4>
00201  * <table>
00202  * <tr> <td> Generator G </td> <td> Project(G,(a,c,g,e),Result) </td> </tr>
00203  * <tr>
00204  * <td> @image html tmp_project_g.png </td>
00205  * <td> @image html tmp_project_prog.png </td>
00206  * </tr>
00207  * </table> 
00208  *
00209  * @ingroup GeneratorFunctions
00210  */
00211 void Project(const Generator& rGen, const EventSet& rProjectAlphabet, Generator& rResGen);
00212 
00213 /**
00214  * Minimized deterministic projection. 
00215  *
00216  * See also Project(const Generator&, const EventSet&, Generator&).
00217  * This version tries to be transparent on event attributes: if
00218  * argument attributes match and if the result can take the respective
00219  * attributes, then they are copied; it is considered an error if 
00220  * argument attributes do not match.
00221  *
00222  * @param rGen
00223  *   Reference to generator
00224  * @param rProjectAlphabet
00225  *   Projection alphabet
00226  * @param rResGen
00227  *   Reference to resulting deterministic generator
00228  *
00229  *
00230  * @ingroup GeneratorFunctions
00231  */
00232 void aProject(const Generator& rGen, const EventSet& rProjectAlphabet, Generator& rResGen);
00233 
00234 /**
00235  * Language projection.
00236  *
00237  * See also aProjectNonDet(const Generator&, const EventSet&).
00238  * This version tries to be transparent on event attributes: result maintains
00239  * its attributes. 
00240  *
00241  * @param rGen
00242  *   Reference to generator
00243  * @param rProjectAlphabet
00244  *   Projection alphabet
00245  *
00246  * @ingroup GeneratorFunctions
00247  */
00248 void aProjectNonDet(Generator& rGen, const EventSet& rProjectAlphabet);
00249 
00250 
00251 /**
00252  * Minimized Deterministic projection. 
00253  * 
00254  * Projects the generated and marked languages to a subalphabet of the original alphabet, 
00255  * and subsequently calls Deterministic and StateMin to construct a deterministic minimal
00256  * realisation of the result. The input generator does not need to be deterministic.
00257  *
00258  * @param rGen
00259  *   Reference to generator
00260  * @param rProjectAlphabet
00261  *   Projection alphabet
00262  * @param rEntryStatesMap
00263  *   Reference to entry states map, see Deterministic(..) (result)
00264  * @param rResGen
00265  *   Reference to resulting deterministic generator (result)
00266  */
00267 void Project(const Generator& rGen, const EventSet& rProjectAlphabet,
00268           std::map<Idx,StateSet>& rEntryStatesMap, Generator& rResGen);
00269 
00270 /**
00271  * Inverse projection. This adds selfloop transition at every state for
00272  * all missing events.
00273  *
00274  * @param rGen
00275  *   Reference to generator
00276  * @param rProjectAlphabet
00277  *   Alphabet for inverse projection
00278  *
00279  * @ingroup GeneratorFunctions
00280  */
00281 void InvProject(Generator& rGen, const EventSet& rProjectAlphabet);
00282 
00283 /**
00284  * Inverse projection. This adds selfloop transition at every state for
00285  * all missing events. This version tries to be transparent to attributes.
00286  *
00287  * @param rGen
00288  *   Reference to generator
00289  * @param rProjectAlphabet
00290  *   Alphabet for inverse projection
00291  *
00292  * @ingroup GeneratorFunctions
00293  */
00294 void aInvProject(Generator& rGen, const EventSet& rProjectAlphabet);
00295 
00296 
00297 /**
00298  * Inverse projection. This adds selfloop transition at every state for
00299  * all missing events. This version tries to be transparent to attributes.
00300  *
00301  * @param rGen
00302  *   Reference to argumant generator
00303  * @param rProjectAlphabet
00304  *   Alphabet for inverse projection
00305  * @param rResGen
00306  *   Alphabet to result.
00307  *
00308  * @ingroup GeneratorFunctions
00309  */
00310 void aInvProject(const Generator& rGen, const EventSet& rProjectAlphabet, Generator& rResGen);
00311 
00312 
00313 
00314 
00315 
00316 } // namespace faudes
00317 
00318 #define FAUDES_PROJECT_H
00319 #endif 
00320 

libFAUDES 2.20s --- 2011.10.12 --- c++ source docu by doxygen