hio_functions.h

Go to the documentation of this file.
00001 /** @file hio_functions.h Algorithms for hierarchical discrete event systems with inputs and outputs */
00002 
00003 /* Hierarchical IO Systems Plug-In for FAU Discrete Event Systems Library (libfaudes)
00004 
00005    Copyright (C) 2006  Sebastian Perk 
00006    Copyright (C) 2006  Thomas Moor 
00007    Copyright (C) 2006  Klaus Schmidt
00008 
00009 */
00010 
00011 
00012 #ifndef FAUDES_HIO_FUNCTIONS_H
00013 #define FAUDES_HIO_FUNCTIONS_H
00014 
00015 #include "hio_constraint.h"
00016 #include "hio_plant.h"
00017 #include "hio_controller.h"
00018 #include "hio_environment.h"
00019 #include "corefaudes.h"
00020 #include <vector>
00021 #include <stack>
00022 #include <map>
00023 
00024 namespace faudes {
00025 
00026 /**
00027  * CompleteSynth: compute supremal complete and
00028  * controllable (and closed)  sublanguage.
00029  * Computes the supremal complete and
00030  * controllable (and closed)  sublanguage of the
00031  * language generated by rSpec wrt the language
00032  * generated by rPlant and the controllable events
00033  * rCalph.
00034  * Method: iteration of SupCon() and erasing of dead
00035  * states found by IsComplete until a fix point is
00036  * reached.
00037  * Leads to maximal solution as shown in:
00038  * Kumar, Garg, Marcus. "On Supervisory Control of
00039  * sequential behaviors" IEEE Transactions On
00040  * Automatic Control, Vol. 37, 1992, pp. 1978-1985
00041  * 
00042  * More concise version SupConComplete() is under
00043  * construction, see below.
00044  *
00045  * @param rPlant
00046  *   plant generator
00047  * @param rCAlph
00048  *   controllable events
00049  * @param rSpec
00050  *   specification generator
00051  * @param rClosedLoop
00052  *   reference to result
00053  * 
00054  * @return
00055  *   success (true) for nonempty result
00056  *
00057  * @exception Exception
00058  *   - see exceptions of SupCon()
00059  *
00060  * @ingroup hiosysplugin 
00061  */
00062 
00063 bool CompleteSynth(
00064   const Generator& rPlant,
00065   const EventSet rCAlph, 
00066   const Generator& rSpec, 
00067   Generator& rClosedLoop);
00068 
00069 /**
00070  * NormalCompleteSynth: compute normal, complete
00071  * and controllable (and closed)  sublanguage.
00072  * Computes the supremal normal, complete and
00073  * controllable (and closed)  sublanguage  of the
00074  * language generated by rSpec wrt the language
00075  * generated by rPlant, the controllable events
00076  * rCalph and the observable events rOAlph.
00077  * Method: iteration of CompleteSynth() and SupNorm()
00078  * until a fix point is reached.
00079  * Note: Supremality (if existent at all) has not yet been
00080  * considered. The proof of existence and construction
00081  * of both
00082  * -the supremal normal and complete sublanguage and
00083  * -the supremal normal and controllable sublanguage
00084  * can be found in literature, which gives reason for
00085  * hope.
00086  *
00087  * @param rPlant
00088  *   plant generator
00089  * @param rCAlph
00090  *   controllable events
00091  * @param rOAlph
00092  *   observable events
00093  * @param rSpec
00094  *   specification generator
00095  * @param rClosedLoop
00096  *   reference to result
00097  * 
00098  * @return
00099  *   success (true) for nonempty closed loop language
00100  *
00101  * @exception Exception
00102  *   - see exceptions of SupCon() and SupNorm()
00103  * 
00104  * @ingroup hiosysplugin 
00105  *
00106  */
00107  
00108 bool NormalCompleteSynth(
00109   Generator& rPlant, 
00110   const EventSet& rCAlph, 
00111   const EventSet& rOAlph,
00112   const Generator& rSpec,
00113   Generator& rClosedLoop);
00114   
00115 /**
00116  * NormalCompleteSynthNB: compute normal, complete,
00117  * controllable and nonblocking  sublanguage.
00118  * Computes a normal, complete, controllable and
00119  * nonblocking (and closed)  sublanguage  of 
00120  * of the language marked by rSpec wrt the language
00121  * marked by rPlant, the controllable events
00122  * rCalph and the observable events rOAlph.
00123  * Method: iteration of CompleteSynth(), SupNorm()
00124  * and Trim() until a fix point is reached.
00125  * Note: Supremality (if existent at all) has not yet been
00126  * considered. 
00127  *
00128  * @param rPlant
00129  *   plant generator
00130  * @param rCAlph
00131  *   controllable events
00132  * @param rOAlph
00133  *   observable events
00134  * @param rSpec
00135  *   specification generator
00136  * @param rClosedLoop
00137  *   reference to result
00138  * 
00139  * @return
00140  *   success (true) for nonempty closed loop language
00141  *
00142  * @exception Exception
00143  *   - see exceptions of SupCon() and SupNorm()
00144  * 
00145  * @ingroup hiosysplugin 
00146  *
00147  */
00148 bool NormalCompleteSynthNB(
00149   Generator& rPlant, 
00150   const EventSet& rCAlph, 
00151   const EventSet& rOAlph,
00152   const Generator& rSpec,
00153   Generator& rClosedLoop);
00154 
00155 /**
00156  * IoSortCL: returns IO-sorting structure  required
00157  * for closed loops. This structure is the prefix closure of
00158  * the language structure [(Yp(Up+YcUcUp))*(YeUe)*]*
00159  *
00160  * @param rYc
00161  *   alphabet Yc
00162  * @param rUc
00163  *   alphabet Uc
00164  * @param rYp
00165  *   alphabet Yp
00166  * @param rUp
00167  *   alphabet Up
00168  * @param rYe
00169  *   alphabet Ye
00170  * @param rUe
00171  *   alphabet Ue
00172  * 
00173  * @return
00174  *   IO-sorting language generator
00175  *
00176  * @exception Exception
00177  *   - empty parameter(s) (id 0)
00178  *   - non-disjoint parameters (id 0)
00179  * 
00180  * @ingroup hiosysplugin 
00181  *
00182  */
00183 
00184 Generator HioSortCL(
00185   const EventSet& rYc, 
00186   const EventSet& rUc,
00187   const EventSet& rYp, 
00188   const EventSet& rUp,
00189   const EventSet& rYe,
00190   const EventSet& rUe);
00191 
00192 /**
00193  * HioFreeInput:  extend generator by obviously missing
00194  * input transitions. States of the generator in which a
00195  * strict but nonempty subset of the alphabet Input is active
00196  * are extended by transitions to an error state (ErrState1,
00197  * flag Err) such that now the whole Input alphabet is active in
00198  * that state. If the alphabet Output is nonempty, an error
00199  * behaviour (Output Input)* is concatenated to the error state
00200  * using a second error state (ErrState2, flag Err).
00201  * Note that this method only helps making the input free in an
00202  * hio system but does not guarantee a free input.
00203  * Method: the transition relation of all states with at least
00204  * one active AND at least one inactive Input-event is
00205  * extended by transitions such that formerly inactive Input-
00206  * events lead to the first error state in the result.  If the
00207  * parameter Output is nonempty, transitions with all
00208  * Output-events from first error state to the second error
00209  * state, and transitions with all Input-events back to the
00210  * first error state are inserted.
00211  * Note: states with NO active Input-event are ignored.
00212  *
00213  * @param rGen
00214  *   generator
00215  * @param rInput
00216  *   alphabet Input
00217  * @param rOutput
00218  *   alphabet Output
00219  * @param rResGen
00220  *   reference to extended generator (result)
00221  * @param rErrState1
00222  *   symbolic name of first error state; ignored if not
00223  *   rGen.StateNamesEnabled()
00224  * @param rErrState2
00225  *   symbolic name of second error state; ignored if not
00226  *   rGen.StateNamesEnabled()
00227  * @param rErrState1Idx
00228  *   index of first error state (result)
00229  * @param rErrState2Idx
00230  *   index of second error state if inserted (result)
00231  *
00232  * @exception Exception
00233  *   - empty Input-alphabet or non-disjoint Input and Output (id 0)
00234  * 
00235  * @ingroup hiosysplugin 
00236  *
00237  */
00238 
00239 void HioFreeInput(
00240   const Generator& rGen, 
00241   const EventSet& rInput, 
00242   const EventSet& rOutput,
00243   Generator& rResGen,
00244   const std::string& rErrState1, 
00245   const std::string& rErrState2,
00246   Idx& rErrState1Idx,
00247   Idx& rErrState2Idx);
00248 
00249 /**
00250  * HioFreeInput:  extend generator by obviously missing
00251  * input transitions. States of the generator in which a
00252  * strict but nonempty subset of the alphabet Input is active
00253  * are extended by transitions to an error state (ErrState1,
00254  * flag Err) such that now the whole Input alphabet is active in
00255  * that state. If the alphabet Output is nonempty, an error
00256  * behaviour (Output Input)* is concatenated to the error state
00257  * using a second error state (ErrState2, flag Err).
00258  * Note that this method only helps making the input free in an
00259  * hio system but does not guarantee a free input.
00260  * Method: the transition relation of all states with at least
00261  * one active AND at least one inactive Input-event is
00262  * extended by transitions such that formerly inactive Input-
00263  * events lead to the first error state in the result.  If the
00264  * parameter Output is nonempty, transitions with all
00265  * Output-events from first error state to the second error
00266  * state, and transitions with all Input-events back to the
00267  * first error state are inserted.
00268  * Note: states with NO active Input-event are ignored.
00269  *
00270  * @param rGen
00271  *   generator
00272  * @param rInput
00273  *   alphabet Input
00274  * @param rOutput
00275  *   alphabet Output
00276  * @param rResGen
00277  *   reference to extended generator (result)
00278  * @param rErrState1
00279  *   symbolic name of first error state; ignored if not
00280  *   rGen.StateNamesEnabled()
00281  * @param rErrState2
00282  *   symbolic name of second error state; ignored if not
00283  *   rGen.StateNamesEnabled()
00284  *
00285  * @exception Exception
00286  *   - empty Input-alphabet or non-disjoint Input and Output (id 0)
00287  * 
00288  * @ingroup hiosysplugin 
00289  *
00290  */
00291 
00292 void HioFreeInput(
00293   const Generator& rGen, 
00294   const EventSet& rInput, 
00295   const EventSet& rOutput,
00296   Generator& rResGen,
00297   const std::string& rErrState1, 
00298   const std::string& rErrState2);
00299 
00300 /**
00301  * HioFreeInput:  extend generator by obviously missing
00302  * input transitions. States of the generator in which a
00303  * strict but nonempty subset of the alphabet Input is active
00304  * are extended by transitions to an error state (flag Err) 
00305  * such that now the whole Input alphabet is active in
00306  * that state. If the alphabet Output is nonempty, an error
00307  * behaviour (Output Input)* is concatenated to the error state
00308  * using a second error state (flag Err).
00309  * Note that this method only helps making the input free in an
00310  * hio system but does not guarantee a free input.
00311  * Method: the transition relation of all states with at least
00312  * one active AND at least one inactive Input-event is
00313  * extended by transitions such that formerly inactive Input-
00314  * events lead to the first error state in the result.  If the
00315  * parameter Output is nonempty, transitions with all
00316  * Output-events from first error state to the second error
00317  * state, and transitions with all Input-events back to the
00318  * first error state are inserted.
00319  * Note: states with NO active Input-event are ignored.
00320  *
00321  * @param rGen
00322  *   generator
00323  * @param rInput
00324  *   alphabet Input
00325  * @param rOutput
00326  *   alphabet Output
00327  * @param rResGen
00328  *   reference to extended generator (result)
00329  *
00330  * @exception Exception
00331  *   - empty Input-alphabet or non-disjoint Input and Output (id 0)
00332  * 
00333  * @ingroup hiosysplugin 
00334  *
00335  */
00336 void HioFreeInput(
00337   const Generator& rGen, 
00338   const EventSet& rInput, 
00339   const EventSet& rOutput,
00340   Generator& rResGen);
00341 
00342 /**
00343  * HioFreeInput:  extend HioPlant by obviously missing
00344  * input transitions. States of the HioPlant in which a
00345  * strict but nonempty subset of the Up- or Ue-alphabet is active
00346  * are extended by transitions to an error state such that
00347  * now the whole Up- or Ue-alphabet is active in that state.
00348  * Note that this method only helps making the input free in an
00349  * hio system but does not guarantee a free input.
00350  * Method: the transition relation of all states with at least
00351  * one active AND at least one inactive Up- or Ue-event is
00352  * extended by transitions such that formerly inactive Up- or Ue-
00353  * events lead to the Up- or Ue-error state in the result. 
00354  * Note: states with NO active Up- or Ue-event are ignored.
00355  *
00356  * @param rPlant
00357  *   HioPlant
00358  * @param rResPlant
00359  *   reference to extended HioPlant (result)
00360  * 
00361  * @ingroup hiosysplugin 
00362  *
00363  */  
00364 void HioFreeInput(
00365   const HioPlant& rPlant,
00366   HioPlant& rResPlant);
00367 
00368 /**
00369  * HioFreeInput:  extend HioController by obviously missing
00370  * input transitions. States of the HioController in which a
00371  * strict but nonempty subset of the Uc- or Yp-alphabet is active
00372  * are extended by transitions to an error state such that
00373  * now the whole Uc- or Yp-alphabet is active in that state. To
00374  * avoid an additional deadlock violating completeness, an error
00375  * behaviour (Up Yp)* is concatenated to the error state
00376  * using a second error state.
00377  * Note that this method only helps making the input free in an
00378  * hio system but does not guarantee a free input.
00379  * Method: the transition relation of all states with at least
00380  * one active AND at least one inactive Uc- or Yp-event is
00381  * events lead to the Uc- or Yp-error state in the result.
00382  * For each Up-event, a transition to a second error state, and
00383  * for each Yp-event, a transition from the second to the first
00384  * error state is inserted to realise the error behaviour.
00385  * Note: states with NO active Uc- or Yp-event are ignored.
00386  *
00387  * @param rController
00388  *   HioController
00389  * @param rResController
00390  *   reference to extended HioController (result)
00391  * 
00392  * @ingroup hiosysplugin 
00393  *
00394  */    
00395 void HioFreeInput(
00396   const HioController& rController,
00397   HioController& rResController);
00398   
00399 /**
00400  * HioFreeInput:  extend HioEnvironment by obviously missing
00401  * input transitions. States of the HioEnvironment in which a
00402  * strict but nonempty subset of the Ul- or Ye-alphabet is active
00403  * are extended by transitions to an error state such that
00404  * now the whole Ul- or Ye-alphabet is active in that state.To
00405  * avoid an additional deadlock violating completeness, an error
00406  * behaviour (Ue Ye)* is concatenated to the error state
00407  * using a second error state.
00408  * Note that this method only helps making the input free in an
00409  * hio system but does not guarantee a free input.
00410  * Method: the transition relation of all states with at least
00411  * one active AND at least one inactive Ul- or Ye-event is
00412  * events lead to the Ul- or Ye-error state in the result. 
00413  * For each Ue-event, a transition to a second error state, and
00414  * for each Ye-event, a transition from the second to the first
00415  * error state is inserted to realise the error behaviour.
00416  * Note: states with NO active Ul- or Ye-event are ignored.
00417  *
00418  * @param rEnvironment
00419  *   HioEnvironment
00420  * @param rResEnvironment
00421  *   reference to extended HioEnvironment (result)
00422  * 
00423  * @ingroup hiosysplugin 
00424  *
00425  */     
00426 void HioFreeInput(
00427   const HioEnvironment& rEnvironment,
00428   HioEnvironment& rResEnvironment);
00429 
00430 /**
00431  * HioFreeInput:  extend HioConstraint by obviously missing
00432  * input transitions. States of the HioConstraint in which a
00433  * strict but nonempty subset of the U-alphabet is active
00434  * are extended by transitions to an error state such that
00435  * now the whole U-alphabet is active in that state.To
00436  * avoid an additional deadlock violating completeness, an error
00437  * behaviour (U Y)* is concatenated to the error state
00438  * using a second error state.
00439  * Note that this method only helps making the input free in an
00440  * hio system but does not guarantee a free input.
00441  * Method: the transition relation of all states with at least
00442  * one active AND at least one inactive U-event is
00443  * events lead to the U-error state in the result. 
00444  * For each U-event, a transition to a second error state, and
00445  * for each Y-event, a transition from the second to the first
00446  * error state is inserted to realise the error behaviour.
00447  * Note: states with NO active U-event are ignored.
00448  *
00449  * @param rConstraint
00450  *   HioConstraint
00451  * @param rResConstraint
00452  *   reference to extended HioConstraint (result)
00453  * 
00454  * @ingroup hiosysplugin 
00455  *
00456  */   
00457 void HioFreeInput(
00458   const HioConstraint& rConstraint,
00459   HioConstraint& rResConstraint);
00460 
00461 /**
00462  * HioFreeInput:  convenience interface to faudes::HioFreeInput(const HioPlant&, HioPlant)
00463  *
00464  * @param rPlant
00465  *   HioPlant
00466  * @ingroup hiosysplugin 
00467  *
00468  */  
00469 void HioFreeInput(HioPlant& rPlant);
00470 
00471 /**
00472  * HioFreeInput:  convenience interface to faudes::HioFreeInput(const HioController&, HioController)
00473  *
00474  * @param rController
00475  *   HioController
00476  * @ingroup hiosysplugin 
00477  *
00478  */  
00479 void HioFreeInput(HioController& rController);
00480 
00481 /**
00482  * HioFreeInput:  convenience interface to faudes::HioFreeInput(const HioEnvironment&, HioEnvironment)
00483  *
00484  * @param rEnvironment
00485  *   HioEnvironment
00486  * @ingroup hiosysplugin 
00487  *
00488  */  
00489 void HioFreeInput(HioEnvironment& rEnvironment);
00490 
00491 /**
00492  * HioFreeInput:  convenience interface to faudes::HioFreeInput(const HioConstraint&, HioConstraint)
00493  *
00494  * @param rConstraint
00495  *   HioConstraint
00496  * @ingroup hiosysplugin 
00497  *
00498  */  
00499 void HioFreeInput(HioConstraint& rConstraint);
00500 
00501 
00502 //**********************************************************
00503 //******************** IO-shuffle ************************
00504 //**********************************************************
00505 
00506 /**
00507  * MarkHioShuffle: marking rule for HioShuffle()  in case of
00508  * marked parameters rGen1 and rGen2 - UNDER CONSTRUCTION.
00509  *
00510  * Method:
00511  * Strings ending with events from rGen1 are marked according
00512  * to rGen1,  strings ending with  events from rGen2 are marked
00513  * according to rGen2.
00514  *
00515  * @param rGen1
00516  *   First generator
00517  * @param rGen2
00518  *   Second generator
00519  * @param rReverseCompositionMap
00520  *   map from rGen1 and rGen2 state indeces to respective
00521  *   state indeces of result
00522  * @param rShuffle
00523  *   Shuffle  of rGen1 and rGen2 that shall receive marking
00524  *
00525  * @ingroup hiosysplugin
00526  *
00527  */
00528 void MarkHioShuffle(
00529   const Generator& rGen1,
00530   const Generator& rGen2,
00531     const std::map< std::pair<Idx,Idx>, Idx >& rReverseCompositionMap,
00532   Generator& rShuffle);
00533 
00534 /**
00535  * CheapAltAnB: returns Generator of the following
00536  * specification: "After a maximum of n (=depth) pairs of
00537  * A-transitions, a B-transition has to occur!".
00538  *
00539  * @param rAset
00540  *   alphabet A
00541  * @param rBset
00542  *   alphabet B
00543  * @param Depth
00544  *   depth of alternation
00545  * @param rAltAnB
00546  *   generator of AnB-specification
00547  *
00548  * @exception Exception
00549  *   - n less than 1 (id 0)
00550  *   - rAset empty (id 0)
00551  *   - rBset empty (id 0)
00552  * 
00553  * @ingroup hiosysplugin 
00554  *
00555  */
00556 void CheapAltAnB(
00557   const EventSet rAset, 
00558   const EventSet rBset,
00559   const int Depth,
00560   Generator& rAltAnB);
00561 
00562 /**
00563  * CheapAltAB: returns Generator of the following
00564  * specification: "After a maximum of n (=depth) pairs of
00565  * A-transitions, a B-transition has to occur and vice-versa!".
00566  *
00567  * @param rAset
00568  *   alphabet A
00569  * @param rBset
00570  *   alphabet B
00571  * @param Depth
00572  *   depth of alternation
00573  * @param rAltAB
00574  *   generator of AB-specification
00575  *
00576  * @exception Exception
00577  *   - n less than 1 (id 0)
00578  *   - rAset empty (id 0)
00579  *   - rBset empty (id 0)
00580  * 
00581  * @ingroup hiosysplugin 
00582  *
00583  */
00584 void CheapAltAB(
00585   const EventSet rAset, 
00586   const EventSet rBset,  
00587   const int Depth,
00588   Generator& rAltAB);
00589   
00590 /**
00591  * MarkAlternationAB: returns Generator marking the
00592  * alternation of Aset-transitions with Bset-transitions.
00593  * More docu will be provided soon.
00594  *
00595  * @param rAset
00596  *   alphabet A
00597  * @param rBset
00598  *   alphabet B
00599  * @param rAltAB
00600  *   recognizer of AB-alternation
00601  *
00602  * @exception Exception
00603  *   - rAset empty (id 0)
00604  *   - rBset empty (id 0)
00605  * 
00606  * @ingroup hiosysplugin 
00607  *
00608  */
00609 void MarkAlternationAB(
00610   const EventSet rAset, 
00611   const EventSet rBset,
00612   Generator& rAltAB);
00613 
00614 /**
00615  * HioShuffleUnchecked:  IO-shuffle of rPlantA and rPlantB
00616  * according to definition, no parameter check. Moreover: marking
00617  * of alternation according to MarkAlternationAB().
00618  * 
00619  * TODO: 'checked' version
00620  *
00621  * @param rPlantA
00622  *   plant A generator
00623  * @param rPlantB
00624  *   plant B generator
00625  * @param rYp
00626  *   alphabet Yp
00627  * @param rUp
00628  *   alphabet Up
00629  * @param rYe
00630  *   alphabet Ye
00631  * @param rUe
00632  *   alphabet Ue
00633   * @param rIOShuffAB
00634  *   reference to I/O-shuffle generator
00635  * 
00636  * @ingroup hiosysplugin 
00637  *
00638  */
00639 void HioShuffleUnchecked(
00640   const Generator& rPlantA, 
00641   const Generator& rPlantB, 
00642   const EventSet& rYp,
00643   const EventSet& rUp, 
00644   const EventSet& rYe, 
00645   const EventSet& rUe,
00646   Generator& rIOShuffAB);
00647 
00648 /**
00649  * HioShuffle:  IO-shuffle of rPlantA and rPlantB according
00650  * to definition. Moreover: marking of alternation
00651  * according to MarkAlternationAB().
00652  * 
00653  *
00654  * @param rPlantA
00655  *   plant A generator
00656  * @param rPlantB
00657  *   plant B generator
00658  * @param rYp
00659  *   alphabet Yp
00660  * @param rUp
00661  *   alphabet Up
00662  * @param rYe
00663  *   alphabet Ye
00664  * @param rUe
00665  *   alphabet Ue
00666   * @param rIOShuffAB
00667  *   reference to I/O-shuffle generator
00668  *
00669  * @exception Exception
00670  *   - empty or non-disjoint alphabets rYp, rUp, rYe, rUe (id 0). 
00671  *   - plant A or plant B not in HioPlantForm (id 0). 
00672  * 
00673  * @ingroup hiosysplugin 
00674  *
00675  */
00676 void HioShuffle(
00677   const Generator& rPlantA, 
00678   const Generator& rPlantB, 
00679   const EventSet& rYp,
00680   const EventSet& rUp, 
00681   const EventSet& rYe, 
00682   const EventSet& rUe,
00683   Generator& rIOShuffAB);
00684   
00685 /**
00686  * HioShuffle:  IO-shuffle of rPlantA and rPlantB according
00687  * to definition. Moreover: alternation of depth
00688  * Depth (see CheapAltAB()) between A- and B-events (no
00689  * alternation for Depth=1) and marking of alternation
00690  * according to MarkAlternationAB().
00691  *
00692  * @param rPlantA
00693  *   HioPlant A
00694  * @param rPlantB
00695  *   HioPlant B
00696   * @param rIOShuffAB
00697  *   reference to composed HioPlant
00698  *
00699  * @exception Exception
00700  *   - todo...
00701  * 
00702  * @ingroup hiosysplugin 
00703  *
00704  */  
00705 void HioShuffle(
00706   const HioPlant& rPlantA, 
00707   const HioPlant& rPlantB,
00708   HioPlant& rIOShuffAB);
00709 
00710 //******************** old version: no marking, forced alternation ************************
00711 /**
00712  * HioShuffleTU:  IO-shuffle of rPlantA and rPlantB according
00713  * to definition with additional forced alternation of depth
00714  * Depth (see CheapAltAB()) between A- and B-events.
00715  * -> frozen version for transport unit example
00716  *
00717  * @param rPlantA
00718  *   plant A generator
00719  * @param rPlantB
00720  *   plant B generator
00721  * @param rYp
00722  *   alphabet Yp
00723  * @param rUp
00724  *   alphabet Up
00725  * @param rYe
00726  *   alphabet Ye
00727  * @param rUe
00728  *   alphabet Ue
00729  * @param Depth
00730  *   depth of alternation
00731    * @param rIOShuffAB
00732  *   reference to I/O-shuffle generator
00733  *
00734  * @exception Exception
00735  *   - todo...
00736  * 
00737  * @ingroup hiosysplugin 
00738  *
00739  */
00740 void HioShuffleTU(
00741   const Generator& rPlantA, 
00742   const Generator& rPlantB, 
00743   const EventSet& rYp,
00744   const EventSet& rUp, 
00745   const EventSet& rYe, 
00746   const EventSet& rUe,
00747   const int Depth,
00748   Generator& rIOShuffAB);
00749 
00750 //**********************************************************
00751 //******************** Cycles ************************
00752 //**********************************************************
00753 
00754 /**
00755  * SearchYclessSCC: Search for strongly connected ycless
00756  * components (YC-less SCC's). This function partitions the
00757  * stateset of a generator into equivalent classes such that
00758  * states x1 and x2 are equivalent iff there is a ycless
00759  * path from x1 to x2 and a ycless path from x2 to x1.
00760  * "Trivial" SCC's consisting of one state without non-Yc-
00761  * selfloop are omitted, SCC's consisting exclusively of
00762  * unmarked states are stored in rUnMarkedSccSet; all OTHER
00763  * SCC's are collected in rSccSet. Their roots (i.e. that
00764  * state of each SCC that has been visited first during depth
00765  * first search of the generator) are collected in rRoots.
00766  * This function is built on the algorithm based on a depth
00767  * first search presented in:
00768  * "Aho, Hopcroft, Ullman:
00769  * The Design and Analysis of Computer Algorithms"
00770  * Most of the comments in this function have been literally
00771  * taken from this book!
00772  * An api with generator and Yc-events as input parameters
00773  * and the set of YC-less SCC's as output parameters is
00774  * provided right below this method.
00775  *
00776  * @param state
00777  *   State, from which the current recursion is started.
00778  * @param rcount
00779  *   Denotes the current depth of the recursion.
00780  * @param rGen
00781  *   investigated generator
00782  * @param rYc
00783  *   alphabet Yc
00784  * @param UnMarkedOnly
00785  *   if set true, being unmarked is an additional condition for equivalence of states
00786  * @param rNewStates
00787  *   Set of states that up to now were not found by the
00788  *   depth first search.
00789  * @param rSTACK
00790  *   Stack of state indeces.
00791  * @param rStackStates
00792  *   Set of states whose indeces are on STACK.
00793  * @param rDFN
00794  *   Map assigning to each state idx its Depth-First Number.
00795  * @param rLOWLINK
00796  *   Map assigning to each state its LOWLINK Number.
00797  * @param rSccSet
00798  *   Set of YC-less strongly connected components (result).
00799  * @param rRoots
00800  *   Set of states that each are root of some SCC (result).
00801  *
00802  * @exception Exception
00803  *   - todo...
00804  * 
00805  * @ingroup hiosysplugin 
00806  * 
00807  */
00808 void SearchYclessScc(
00809   const Idx state, 
00810   int& rcount,      // why is this a ref?
00811   const Generator& rGen,
00812   const EventSet& rYc,
00813   const bool UnMarkedOnly,
00814   StateSet&  rNewStates,
00815   std::stack<Idx>& rSTACK, 
00816   StateSet& rStackStates,
00817   std::map<const Idx, int>& rDFN,
00818   std::map<const Idx, int>& rLOWLINK,
00819   std::set<StateSet>& rSccSet,
00820   StateSet& rRoots);
00821 
00822 /**
00823  * YclessSCC: Search for strongly connected ycless
00824  * components (YC-less SCC's) - convenience api. See
00825  * SearchYclessSCC() for docu.
00826  * 
00827  * @param rGen
00828  *   investigated generator
00829  * @param rYc
00830  *   alphabet Yc
00831  * @param rSccSet
00832  *   Set of YC-less strongly connected components (result).
00833  * @param rRoots
00834  *   Set of states that each are root of some SCC (result).
00835  *
00836  * @return
00837  *   true if YclessSCC's have been found, false if not.
00838  *
00839  * @exception Exception
00840  *   - todo...
00841  * 
00842  * @ingroup hiosysplugin 
00843  *
00844  */
00845 bool YclessScc(
00846   const Generator& rGen,
00847   const EventSet& rYc,
00848   std::set<StateSet>& rSccSet,
00849   StateSet& rRoots);
00850   
00851 
00852 /**
00853  * YclessUnmarkedSCC: Search for strongly connected ycless
00854  * components (YC-less SCC's) consisting of unmarked states only.
00855  * Uses SearchYclessSCC().
00856  * 
00857  * @param rGen
00858  *   investigated generator
00859  * @param rYc
00860  *   alphabet Yc
00861  * @param rSccSet
00862  *   Set of unmarked YC-less strongly connected components (result).
00863  * @param rRoots
00864  *   Set of states that each are root of some SCC (result).
00865  *
00866  * @return
00867  *   true if unmarked YclessSCC's have been found, false if not.
00868  *
00869  * @exception Exception
00870  *   - todo...
00871  * 
00872  * @ingroup hiosysplugin 
00873  *
00874  */
00875 bool YclessUnmarkedScc(
00876   const Generator& rGen,
00877   const EventSet& rYc,
00878   std::set<StateSet>& rSccSet,
00879   StateSet& rRoots);
00880 
00881 /**
00882  * YclessSCC: Search for strongly connected ycless
00883  * components (YC-less SCC's) - convenience api. See
00884  * SearchYclessSCC() for docu.
00885  * 
00886  * @param rGen
00887  *   investigated generator
00888  * @param rYc
00889  *   alphabet Yc
00890  * @param rSccSet
00891  *   Set of YC-less strongly connected components (result).
00892  *
00893  * @return
00894  *   true if YclessSCC's have been found, false if not.
00895  *
00896  * @exception Exception
00897  *   - todo...
00898  * 
00899  * @ingroup hiosysplugin 
00900  *
00901  */
00902 bool YclessSCC(
00903   const Generator& rGen,
00904   const EventSet& rYc,
00905   std::set<StateSet>& rSccSet);
00906 
00907 /**
00908  * IsYcLive: This function checks if generator is Yc-live.
00909  * Method: using YclessSCC(), the function checks if no Yc-less
00910  * SCC is found.
00911  * 
00912  * @param rGen
00913  *   investigated generator
00914  * @param rYc
00915  *   alphabet Yc
00916  *
00917  * @return
00918  *   true if Generator is YcLive.
00919  *
00920  * @exception Exception
00921  *   - todo...
00922  * 
00923  * @ingroup hiosysplugin 
00924  *
00925  */
00926 bool IsYcLive(
00927   const Generator& rGen,
00928   const EventSet& rYc);
00929   
00930 /**
00931  * WriteStateSets: Write set of StateSet's to console (indeces).
00932  * Useful to output partitions over statesets like e.g. the
00933  * set of strongly connected components. Also serves as
00934  * template for walkthrough through each state of a set of
00935  * statesets.
00936  * 
00937  * @param rStateSets
00938  *   Reference to set of StateSets (result).
00939  *
00940  * @exception Exception
00941  *   - todo?
00942  * 
00943  * @ingroup hiosysplugin 
00944  *
00945  */
00946 void WriteStateSets(
00947   const std::set<StateSet>& rStateSets);
00948   
00949 /**
00950  * WriteStateSets: Write set of StateSet's to console (symbolic
00951  * state names taken from rGen).
00952  * Useful to output partitions over statesets like e.g. the
00953  * set of strongly connected components. Also serves as
00954  * template for walkthrough through each state of a set of
00955  * statesets.
00956  *
00957  * @param rGen
00958  *   Generator holding symbolic state names.
00959  * @param rStateSets
00960  *   Reference to set of StateSets (result).
00961  *
00962  * @exception Exception
00963  *   - todo?
00964  * 
00965  * @ingroup hiosysplugin 
00966  *
00967  */  
00968 void WriteStateSets(
00969   const Generator& rGen,
00970   const std::set<StateSet>& rStateSets);
00971 
00972 /**
00973  * SCCEntries: figure entry states and entry transitions of
00974  * strongly connected components rSccSet of rGen. Entry
00975  * states are the set of states of the SCC that are initial
00976  * state or direct successor of some state not belonging to
00977  * this SCC (i.e. belonging to a different or no SCC). Entry
00978  * transitions are the set of respective transitions leading
00979  * to an entrystate of some SCC from a state not belonging
00980  * to this SCC.
00981  * 
00982  * @param rGen
00983  *   generator holding SCC's of rSccSet
00984  * @param rSccSet
00985  *   generator holding SCC's of rSccSet
00986  * @param rEntryStates
00987  *   reference to set of entry states of all SCC's (result)
00988  * @param rEntryTransSet
00989  *   reference to set of entry transitions, sorted by X2
00990  *   (result)
00991  *
00992  * @exception Exception
00993  *   - todo: if FAUDES_CHECKED: check if elements of rSccSet
00994  *   are all subsets of StateSet of rGen.
00995  * 
00996  * @ingroup hiosysplugin 
00997  *
00998  */
00999 void SccEntries(
01000   const Generator& rGen,
01001   const std::set<StateSet>& rSccSet,
01002   StateSet& rEntryStates,
01003   TransSetX2EvX1& rEntryTransSet);
01004 
01005 /**
01006  * cloneSCC: makes a copy (clone) of strongly connected
01007  * component (rSCC) of the generator and moves all
01008  * transitions leading to some entry state EntryState of
01009  * this SCC to the copy of EntryState. If this is carried
01010  * out for n-1 of all n entry states of the SCC, then, in
01011  * the generator, this one SCC is transformed into n SCC's
01012  * with one unique entry state each.
01013  * The set of SCC's is extended by the clone-SCC. The set of
01014  * entry states is extended by the (unique) entry state of
01015  * the clone-SCC.
01016  * Note: all added states are equivalent to some state in
01017  * the original generator, the behaviour is not changed.
01018  * The basic idea of this algorithm id taken from
01019  * [Jéron,Marchand,Rusu,Tschaen] "Ensuring the conformance
01020  * of reactive discrete-event systems using supervisory
01021  * control" (CDC'03)
01022  * todo: check const parameters
01023  * 
01024  * @param rGen
01025  *   generator holding SCC's of rSccSet
01026  * @param rScc
01027  *   SCC of rGen that is to be cloned // Perk: check if idx of rSccSet is better?
01028  * @param rSccSet
01029  *   set of all SCC's of rGen
01030  * @param EntryState
01031  *   one of the entry states of this SCC
01032  * @param rEntryStates
01033  *   set of entry states of this SCC
01034  * @param rEntryTransSet
01035  *   set of respective transitions to the entry states,
01036  *   sorted by X2
01037  *
01038  * @exception Exception
01039  *   - todo: exceptions, e.g. for rEntryState not subset of
01040  *   rEntryStates not subset of rScc not element of rSccSet,
01041  *   elements of rSccSet not subset of rGen.States() etc.
01042  * 
01043  * @ingroup hiosysplugin  
01044  *
01045  */
01046 
01047 void CloneScc(
01048   Generator& rGen,
01049   const StateSet& rScc,
01050   std::set<StateSet>& rSccSet,
01051   const Idx EntryState,
01052   StateSet& rEntryStates, 
01053   TransSetX2EvX1& rEntryTransSet);
01054 
01055 /**
01056  * CloneUnMarkedSCC: makes a copy (clone) of strongly connected
01057  * unmarked component (rSCC)  of rGen.
01058  * 
01059  * @ingroup hiosysplugin 
01060 */
01061 
01062 void CloneUnMarkedScc(
01063   Generator& rGen,
01064   const StateSet& rScc,
01065   const Idx EntryState,
01066   const StateSet& rEntryStates, 
01067   TransSetX2EvX1& rEntryTransSet);
01068 
01069 /**
01070  * YcAcyclic: Computes the supremal(?) Yc-acyclic
01071  * sublanguage of L(Gen). Procedure:
01072  * 1) Find Yc-less SCC's with YclessScc(...)
01073  * 2) transform SCC's with n entry states to n SCC's with
01074  * one unique entry state.
01075  * 3) erase transitions leading from a state of some SCC to
01076  * the entry state of this SCC's.
01077  * 4) repeat 1)-3) until no more Yc-less SCC is found, i.e.
01078  * rResGen generates the supremal YcAcyclic sublanguage of
01079  * the language generated by rGen.
01080  *
01081  * @param rGen
01082  *   input generator
01083  * @param rYc
01084  *   alphabet Yc
01085  * @param rResGen
01086  *   generator of supremal YcAcyclic sublanguage
01087  *
01088  * @exception Exception
01089  *   - todo: rYc must be subset of rGen.Alphabet()
01090  * 
01091  * @ingroup hiosysplugin 
01092  *
01093 */
01094 void YcAcyclic(
01095   const Generator& rGen,
01096   const EventSet& rYc,
01097   Generator& rResGen);
01098 
01099 //**********************************************************
01100 //******************** hio synthesis ************************
01101 //**********************************************************
01102   
01103 /**
01104  * ConstrSynth_Beta: compute operator constraint Sp for plant under
01105  * environment constraint Sl such that plant is complete & Yp-live wrt
01106 * both constraints - Beta Version. Plant can be individual or
01107  * composed, ie Plant=Lpe || Le, or Plant=Lpe1 ||io Lpe2 || Lel || Ll,
01108  * ie composition of plant and envconstr, or composition of HioShuffle
01109  * of two plants with environment and envconstr.
01110  * Parameter rLocConstr is optional and may contain environment
01111  * constraints for Lpe1 and Lpe2; rOpConstraint is computed such that
01112  * rLocConstr is met under rOpConstraint.
01113  * More and better docu will follow in future version.
01114  * 
01115  * @param rPlant
01116  *   model of plant under environment constraint. 
01117  * @param rYp
01118  *   alphabet YP
01119  * @param rUp
01120  *   alphabet UP
01121  * @param rLocConstr
01122  *   reference to optional local constraints
01123  * @param rOpConstraint
01124  *   reference to operator constraint
01125  * 
01126  * @ingroup hiosysplugin 
01127  * 
01128 */
01129 void ConstrSynth_Beta(
01130         Generator& rPlant,
01131   const EventSet& rYp,
01132   const EventSet& rUp,
01133   const Generator& rLocConstr,
01134   Generator& rOpConstraint);
01135 
01136 /**
01137  * HioSynthUnchecked: I/O controller synthesis procedure, no
01138  * parameter check. Main hio synthesis algorithm suitable for both
01139  * the monolithic and the hierarchical case, see also respective api's
01140  * HioSynth(with parameter check), HioSynthMonolithic and
01141  * HioSynthHierarchical. The result rController realises a solution to
01142  * the I/O controller synthesis problem (S_PE,S_C,S_P,S_E,S_SpecCE).
01143  * 
01144  * @param rPlant
01145  *   plant model generator:
01146  *   - monolithic case: I/O plant to be controlled;
01147  *   - hierarchical case: parallel composition of group
01148  * (I/O-shuffle) of n I/O   plants S_PEi (or their
01149  * abstractions) with the environment model S_EL for 
01150  * this group.
01151  * @param rSpec
01152  *   generator of desired behaviour of the external closed
01153  *   loop over alphabet SigmaCE. Must be in I/O plant form.
01154  * @param rConstr
01155  *   external constraint that may be assumed:
01156  *   - monolithic case: composition of constraints S_C and
01157  *   S_E
01158  *   - hierarchical case: composition of constraints S_C and
01159  *   S_L
01160  * @param rLocConstr
01161  *   internal constraint that has to be achieved by the I/O
01162  *   controller for the closed loop:
01163  *   - monolithic case: generator of constraint S_P
01164  *   - hierarchical case: parallel composition of
01165  *     constraints S_Pi   and S_Ei
01166  * @param rYc
01167  *   alphabet YC
01168  * @param rUc
01169  *   alphabet UC
01170  * @param rYp
01171  *   alphabet YP
01172  * @param rUp
01173  *   alphabet UP
01174  * @param rYel
01175  *   monolithic: alphabet YE, hierarchical: alphabet YL
01176  * @param rUel
01177  *   monolithic: alphabet UE, hierarchical: alphabet UL
01178  * @param rController
01179  *   reference to I/O controller(result)
01180  * 
01181  * @ingroup hiosysplugin 
01182  * 
01183 */
01184 void HioSynthUnchecked(
01185   const Generator& rPlant,
01186   const Generator& rSpec,
01187   const Generator& rConstr,
01188   const Generator& rLocConstr,
01189   const EventSet& rYc,
01190   const EventSet& rUc, 
01191   const EventSet& rYp,
01192   const EventSet& rUp, 
01193   const EventSet& rYel,
01194   const EventSet& rUel,
01195   Generator& rController);
01196   
01197 /**
01198  * HioSynthUnchecked: I/O controller synthesis procedure.
01199  * Main hio synthesis algorithm suitable for both
01200  * the monolithic and the hierarchical case, see also respective api's
01201  * HioSynthMonolithic and HioSynthHierarchical.
01202  * The result rController realises a solution to the I/O controller
01203  *  synthesis problem (S_PE,S_C,S_P,S_E,S_SpecCE).
01204  * 
01205  * @param rPlant
01206  *   plant model generator:
01207  *   - monolithic case: I/O plant to be controlled;
01208  *   - hierarchical case: parallel composition of group
01209  * (I/O-shuffle) of n I/O   plants S_PEi (or their
01210  * abstractions) with the environment model S_EL for 
01211  * this group.
01212  * @param rSpec
01213  *   generator of desired behaviour of the external closed
01214  *   loop. Must be in I/O plant form.
01215  * @param rConstr
01216  *   external constraint that may be assumed:
01217  *   - monolithic case: composition of constraints S_C and
01218  *   S_E
01219  *   - hierarchical case: composition of constraints S_C and
01220  *   S_L
01221  * @param rLocConstr
01222  *   internal constraint that has to be achieved by the I/O
01223  *   controller for the closed loop:
01224  *   - monolithic case: generator of constraint S_P
01225  *   - hierarchical case: parallel composition of
01226  *     constraints S_Pi   and S_Ei
01227  * @param rYc
01228  *   alphabet YC
01229  * @param rUc
01230  *   alphabet UC
01231  * @param rYp
01232  *   alphabet YP
01233  * @param rUp
01234  *   alphabet UP
01235  * @param rYel
01236  *   monolithic: alphabet YE, hierarchical: alphabet YL
01237  * @param rUel
01238  *   monolithic: alphabet UE, hierarchical: alphabet UL
01239  * @param rController
01240  *   reference to I/O controller(result)
01241  *
01242  * @exception Exception
01243  *   - empty or non-disjoint alphabets rYc, rUc, rYp, rUp, rYel, rUel (id 0). 
01244  *   - rSpec not in HioPlantForm (id 0). 
01245  *   - alphabet mismatch between plant or constraints and spec (id 0). 
01246  * 
01247  * @ingroup hiosysplugin 
01248  * 
01249 */
01250 void HioSynth(
01251   const Generator& rPlant,
01252   const Generator& rSpec,
01253   const Generator& rConstr,
01254   const Generator& rLocConstr,
01255   const EventSet& rYc,
01256   const EventSet& rUc, 
01257   const EventSet& rYp,
01258   const EventSet& rUp, 
01259   const EventSet& rYel,
01260   const EventSet& rUel,
01261   Generator& rController);
01262   
01263 /**
01264  * HioSynthMonolithic: I/O controller synthesis procedure for
01265  * monolithic plant. The result rController realises a solution to
01266  * the I/O controller synthesis problem (S_PE,S_C,S_P,S_E,S_SpecCE).
01267  * 
01268  * @param rPlant
01269  *   I/O plant to be controlled; must be in I/O plant form (tested if
01270  *   FAUDES_CHECKED); must be complete and Yp-live wrt. Sp and
01271  *   Se (not tested).
01272  * @param rSpec
01273  *   I/O plant model of desired behaviour of the external closed
01274  *   loop. Must be in I/O plant form (tested if FAUDES_CHECKED);
01275  *    must be complete and Yp-live wrt. Sc and Se (not tested).
01276  * @param rSc
01277  *   external operator constraint that may be assumed; I/O constraint form
01278  *   is recommended.
01279  * @param rSp
01280  *   operator constraint for rPlant; is met by admissibility of rController;
01281  *   I/O constraint form  is recommended.
01282  * @param rSe
01283  *   environment constraint that may be assumed; I/O constraint form
01284  *   is recommended.
01285  * @param rController
01286  *   I/O controller solving the I/O controller synthesis problem (result)
01287  * 
01288  * @exception Exception
01289  *   - plant or spec not in HioPlantForm (id 0). 
01290  *   - alphabet mismatch between plant or constraints and spec (id 0). 
01291  *
01292  * @ingroup hiosysplugin 
01293  * 
01294 */
01295 void HioSynthMonolithic(
01296   const HioPlant& rPlant,
01297   const HioPlant& rSpec,
01298   const HioConstraint& rSc,
01299   const HioConstraint& rSp,
01300   const HioConstraint& rSe,
01301   HioController& rController);
01302   
01303 /**
01304  * HioSynthHierarchical: I/O controller synthesis procedure for
01305  * I/O-shuffle of i plants and their interaction via an I/O environment.
01306  * The result rController realises a solution to the I/O controller
01307  *  synthesis problem (S_PE,S_C,S_P,S_E,S_SpecCE) with the external
01308  *  behaviour S_PE of the I/Oshuffle-environment-composition and respects
01309  *  internal constraints Sp_i and Se_i preserving liveness of the
01310  * individual plants.
01311  * 
01312  * @param rHioShuffle
01313  *   I/O plant or group of I/O plants composed by I/O shuffle
01314  * @param rEnvironment
01315  *   environment model for rHioShuffle
01316  * @param rSpec
01317  *   I/O plant model of desired behaviour of the external closed
01318  *   loop. Must be in I/O plant form (tested if FAUDES_CHECKED);
01319  *    must be complete and Yp-live wrt. Sc and Se (not tested).
01320  * @param rIntConstr
01321  *   parallel composition of constraints Sp_i and Se_i of the
01322  *   individual plants composed to rHioShuffle
01323  * @param rSc
01324  *   external operator constraint that may be assumed; I/O constraint form
01325  *   is recommended.
01326  * @param rSl
01327  *   environment constraint that may be assumed; I/O constraint form
01328  *   is recommended.
01329  * @param rController
01330  *   I/O controller solving the I/O controller synthesis problem (result)
01331  * 
01332  * @exception Exception
01333  *   - HioShuffle or spec not in HioPlantForm (id 0). 
01334  *   - Environment not in HioEnvironmentForm (id 0). 
01335  *   - alphabet mismatch between plant, environment, spec and constraints (id 0). 
01336  *
01337  * @ingroup hiosysplugin 
01338  * 
01339 */
01340 void HioSynthHierarchical(
01341   const HioPlant& rHioShuffle,
01342   const HioEnvironment& rEnvironment,
01343   const HioPlant& rSpec,
01344   const Generator& rIntConstr,
01345   const HioConstraint& rSc,
01346   const HioConstraint& rSl,
01347   HioController& rController);
01348   
01349 //#####################################
01350 // #### end of hio_functions - below just archive ########
01351 //#####################################
01352 
01353 //HioShuffle_Musunoi() - special version for HioModule. Will be changed to std HioShuffle.
01354 void HioShuffle_Musunoi(
01355   const HioPlant& rPlantA, 
01356   const HioPlant& rPlantB, 
01357   int depth, 
01358   Generator& rIOShuffAB) ;
01359 
01360 //HioSynth_Musunoi() - special version for HioModule. Will be changed to std HioSynth.
01361 void HioSynth_Musunoi(
01362   const Generator& rPlant,
01363   const HioPlant& rSpec,
01364   const Generator& rConstr,
01365   const Generator& rLocConstr,
01366   const EventSet& rYp,
01367   const EventSet& rUp, 
01368   Generator& rController);
01369 }
01370 
01371 
01372 #endif

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