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

libFAUDES 2.16b --- 2010-9-8 --- c++ source docu by doxygen 1.6.3