libFAUDES

Sections

Index

syn_supcon.h

Go to the documentation of this file.
00001 /** @file syn_supcon.h Supremal controllable sublanguage */
00002 
00003 /* FAU Discrete Event Systems Library (libfaudes)
00004 
00005    Copyright (C) 2006  Bernd Opitz
00006    Copyright (C) 2007  Thomas Moor
00007    Exclusive copyright is granted to Klaus Schmidt
00008 
00009    This library is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU Lesser General Public
00011    License as published by the Free Software Foundation; either
00012    version 2.1 of the License, or (at your option) any later version.
00013 
00014    This library is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    Lesser General Public License for more details.
00018 
00019    You should have received a copy of the GNU Lesser General Public
00020    License along with this library; if not, write to the Free Software
00021    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00022 
00023  
00024 #ifndef FAUDES_SUPCON_H
00025 #define FAUDES_SUPCON_H
00026 
00027 #include "corefaudes.h"
00028 #include <stack>
00029 
00030 namespace faudes {
00031     
00032 
00033 
00034 /**
00035  * Test controllability
00036  *
00037  * Tests whether the candidate supervisor H is controllable w.r.t.
00038  * the plant G. This implementation does not require the supervisor H to 
00039  * represent a sublanguage of the plant G. 
00040  * 
00041  * Parameter restrictions: both generators must be deterministic and 
00042  * have the same alphabet.
00043  *
00044  *
00045  * @param rPlantGen
00046  *   Plant G
00047  * @param rCAlph
00048  *   Controllable events
00049  * @param rSupCandGen
00050  *   Supervisor candidate H
00051  *
00052  * @exception Exception
00053  *   - alphabets of generators don't match (id 100)
00054  *   - plant generator nondeterministic (id 201)
00055  *   - specification generator nondeterministic (id 203)
00056  *   - plant and Spec generator nondeterministic (id 204)
00057  *
00058  * @return 
00059  *   true / false
00060  *
00061  * @ingroup SynthesisPlugIn
00062  */
00063 bool IsControllable(
00064   const vGenerator& rPlantGen, 
00065   const EventSet&  rCAlph,
00066   const vGenerator& rSupCandGen);
00067 
00068 
00069 /**
00070  * Test controllability.
00071  *
00072  * Tests whether the candidate supervisor H is controllable w.r.t.
00073  * the plant G. This implementation does not require the supervisor H to 
00074  * represent a sublanguage of the plant G. 
00075  * 
00076  *
00077  * If the candidate fails to be controllable, this version will return a set of 
00078  * "critical" states of the candidate supervisor. These states are characterised by 
00079  *  (a) being reachable in the parallel composition of plant and supervisor 
00080  *  (b) disabeling an uncontrollable transition of the plant
00081  *
00082  * Parameter restrictions: both generators must be deterministic and 
00083  * have the same alphabet.
00084  *
00085  * @param rPlantGen
00086  *   Plant G 
00087  * @param rCAlph
00088  *   Controllable events
00089  * @param rSupCandGen
00090  *   Supervisor candicate H 
00091  * @param rCriticalStates
00092  *   Set of critical states
00093  *
00094  * @exception Exception
00095  *   - alphabets of generators don't match (id 200)
00096  *   - plant generator nondeterministic (id 201)
00097  *   - specification generator nondeterministic (id 203)
00098  *   - plant and Spec generator nondeterministic (id 204)
00099  *
00100  * @return 
00101  *   true / false
00102  *
00103  * @ingroup SynthesisPlugIn
00104  */
00105 bool IsControllable(
00106   const vGenerator& rPlantGen, 
00107   const EventSet&  rCAlph,
00108   const vGenerator& rSupCandGen, 
00109   StateSet& rCriticalStates);
00110 
00111 /** 
00112  * IsControllable wrapper.  
00113  * Wrapper for convenient access via the run-time interface.
00114  */
00115 void IsControllable(
00116   const vGenerator& rPlantGen, 
00117   const EventSet&  rCAlph,
00118   const vGenerator& rSupCandGen, 
00119   bool& rRes);
00120 
00121 /**
00122  * Test controllability. 
00123  *
00124  * Tests whether the candidate supervisor h is controllable w.r.t.
00125  * the plant g; this is a cGenerator wrapper for IsControllable
00126  *
00127  * @param rPlantGen
00128  *   Plant g generator
00129  * @param rSupCandGen
00130  *   Supervisor candidate h generator 
00131  *
00132  * @exception Exception
00133  *   Alphabets of generators don't match (id 500)
00134  *   Plant generator nondeterministic (id 501)
00135  *   Specification generator nondeterministic (id 503)
00136  *   Plant & Spec generator nondeterministic (id 504)
00137  *
00138  * @return 
00139  *   true / false
00140  *
00141  * @ingroup SynthesisPlugIn
00142  */
00143 bool cIsControllable(
00144   const cGenerator& rPlantGen, 
00145   const vGenerator& rSupCandGen);
00146 
00147 
00148 /**
00149  * Nonblocking Supremal Controllable Sublanguage
00150  *
00151  * Computes the supremal nonblocking sublanguage of the specification E that is controllable
00152  * w.r.t. the plant G. The result is given as a trim deterministic generator that 
00153  * may be used to supervise G in order to enforce H. This implementation does not require E 
00154  * to represent a  sublanguage of G
00155  *
00156  * See "C.G CASSANDRAS AND S. LAFORTUNE. Introduction to Discrete Event 
00157  * Systems. Kluwer, 1999." for base algorithm.
00158  *
00159  * Parameter restrictions: both generators must be deterministic and 
00160  * have the same alphabet.
00161  *
00162  *
00163  * @param rPlantGen
00164  *   Plant G
00165  * @param rCAlph
00166  *   Controllable events
00167  * @param rSpecGen
00168  *   Specification Generator E
00169  * @param rResGen
00170  *   Reference to resulting Generator, the
00171  *   minimal restrictive nonblocking supervisor
00172  *
00173  * @exception Exception
00174  *   - alphabets of generators don't match (id 100)
00175  *   - plant nondeterministic (id 201)
00176  *   - spec nondeterministic (id 203)
00177  *   - plant and spec nondeterministic (id 204)
00178  *
00179  * @ingroup SynthesisPlugIn
00180  *
00181  */
00182 void SupConNB(
00183   const vGenerator& rPlantGen, 
00184   const EventSet&  rCAlph,
00185   const vGenerator& rSpecGen, 
00186   vGenerator& rResGen);
00187 
00188 
00189 
00190 /**
00191  * Nonblocking Supremal Controllable Sublanguage 
00192  *
00193  * This is the RTI wrapper for   
00194  * SupConNB(const vGenerator&, const EventSet&, const vGenerator&, vGenerator&).
00195  * Controllability attributes are taken from the plant argument.
00196  * If the result is specified as a cGenerator, attributes will be copied
00197  * from the plant argument.
00198  *
00199  *
00200  * @param rPlantGen
00201  *   Plant cGenerator
00202  * @param rSpecGen
00203  *   Specification Generator
00204  * @param rResGen
00205  *   Reference to resulting Generator, the
00206  *   minimal restrictive nonblocking supervisor
00207  *
00208  * @exception Exception
00209  *   Alphabets of generators don't match (id 100)
00210  *   plant nondeterministic (id 201)
00211  *   spec nondeterministic (id 203)
00212  *   plant and spec nondeterministic (id 204)
00213  *
00214  * @ingroup SynthesisPlugIn
00215  */
00216 void cSupConNB(
00217   const cGenerator& rPlantGen, 
00218   const vGenerator& rSpecGen, 
00219   vGenerator& rResGen);
00220 
00221 
00222 
00223 /**
00224  * Supremal Controllable Sublanguage
00225  *
00226  * Parameter restrictions: both generators must be deterministic and 
00227  * have the same alphabet.
00228  *
00229  * @param rPlantGen
00230  *   Plant G
00231  * @param rCAlph
00232  *   Controllable events
00233  * @param rSpecGen
00234  *   Specification E
00235  * @param rResGen
00236  *   Reference to resulting Generator, the
00237  *   minimal restrictive supervisor
00238  *
00239  * @exception Exception
00240  *   - alphabets of generators don't match (id 100)
00241  *   - plant nondeterministic (id 201)
00242  *   - spec nondeterministic (id 203)
00243  *   - plant and spec nondeterministic (id 204)
00244  *
00245  * @ingroup SynthesisPlugIn
00246  */
00247 void SupCon(
00248   const vGenerator& rPlantGen, 
00249   const EventSet&  rCAlph,
00250   const vGenerator& rSpecGen, 
00251   vGenerator& rResGen);
00252 
00253 
00254 /** 
00255  * Supremal Controllable Sublanguage.
00256  * 
00257  * This is the RTI wrapper for   
00258  * SupCon(const vGenerator&, const EventSet&, const vGenerator&, vGenerator&).
00259  * Controllability attributes are taken from the plant argument.
00260  * If the result is specified as a cGenerator, attributes will be copied
00261  * from the plant argument.
00262  *
00263  * @param rPlantGen
00264  *   Plant cGenerator 
00265  * @param rSpecGen
00266  *   Specification Generator 
00267  * @param rResGen
00268  *   Reference to resulting Generator, the
00269  *   minimal restrictive supervisor
00270  *
00271  * @exception Exception
00272  *   Alphabets of generators don't match (id 100)
00273  *   plant nondeterministic (id 201)
00274  *   spec nondeterministic (id 203)
00275  *   plant and spec nondeterministic (id 204)
00276  *
00277  * @ingroup SynthesisPlugIn
00278  */
00279 void cSupCon(
00280   const cGenerator& rPlantGen, 
00281   const vGenerator& rSpecGen, 
00282   vGenerator& rResGen);
00283 
00284 /** 
00285  * Supremal Controllable Sublanguage.
00286  * 
00287  * Only for deterministic plant + spec. Throws exception if plant or
00288  * spec is nondeterministic.
00289  *
00290  * Real SupCon function
00291  *
00292  * Finds the "largest" sublanguage of h for that language of g is
00293  * controllable with respect to h. Note that the language of h is not
00294  * rtequired to be a a sublanguage of g, but both languages must share 
00295  * the same alphabet.
00296  *
00297  * See "C.G CASSANDRAS AND S. LAFORTUNE. Introduction to Discrete Event 
00298  * Systems. Kluwer, 1999." for base algorithm.
00299  *
00300  * This version creates a "reverse composition map" given as reference
00301  * parameter.
00302  * 
00303  * @param rPlantGen
00304  *   Plant Generator 
00305  * @param rCAlph
00306  *   Controllable events
00307  * @param rSpecGen
00308  *   Specification Generator 
00309  * @param rReverseCompositionMap
00310  *   std::map< std::pair<Idx,Idx>, Idx> as in the parallel composition function
00311  * @param rResGen
00312  *   Reference to resulting Generator, the
00313  *   minimal restrictive supervisor
00314  *
00315  * @exception Exception
00316  *   - alphabets of generators don't match (id 100)
00317  *   - plant nondeterministic (id 201)
00318  *   - spec nondeterministic (id 203)
00319  *   - plant and spec nondeterministic (id 204)
00320  */
00321 void SupCon(
00322   const vGenerator& rPlantGen, 
00323   const EventSet&  rCAlph,
00324   const vGenerator& rSpecGen, 
00325   std::map< std::pair<Idx,Idx>,Idx >& rReverseCompositionMap, 
00326   vGenerator& rResGen);
00327 
00328 
00329 /** 
00330  * Nonblocking Supremal Controllable Sublanguage.
00331  * 
00332  * For deterministic and nondeterministic plant or spec. 
00333  *
00334  * - If rPlantGen is deterministic, rDetPlantGen will be unchanged.
00335  *   rDetPlantBool will be set to false.
00336  *
00337  * - If rSpecGen is deterministic, rDetSpecGen will be unchanged
00338  *   rDetSpecBool will be set to false
00339  *
00340  * - If rPlantGen is nondeterministic, rDetPlantGen will contain deterministic
00341  *   plant generator. rDetPlantBool will be set to true. rPowerStatesPlant will
00342  *   contain the mapping of deterministic states to subsets of nondeterministic
00343  *   states
00344  *
00345  * - If rSpecGen is nondeterministic, rDetPlantGen will contain deterministic
00346  *   spec generator. rDetSpecBool will be set to true. rPowerStatesSpec will
00347  *   contain the mapping of deterministic states to subsets of nondeterministic
00348  *   states
00349  *
00350  * Finds the "largest" sublanguage of h for that language of g is
00351  * controllable with respect to h. Differing from theory the marked
00352  * language of h may not be a sublanguage of g but both must share the
00353  * same alphabet.
00354  *
00355  * See "C.G CASSANDRAS AND S. LAFORTUNE. Introduction to Discrete Event 
00356  * Systems. Kluwer, 1999." for base algorithm.
00357  *
00358  * This version creates a "reverse composition map" given as reference
00359  * parameter.
00360  * 
00361  * @param rPlantGen
00362  *   Plant Generator 
00363  * @param rCAlph
00364  *   Controllable events
00365  * @param rSpecGen
00366  *   Specification Generator 
00367  * @param rReverseCompositionMap
00368  *   std::map< std::pair<Idx,Idx>, Idx> as in the parallel composition function
00369  * @param rDetPlantGen
00370  *   Deterministic plant generator (if rPlantGen is nondeterministic)
00371  * @param rDetSpecGen
00372  *   Deterministic spec generator (if rSpecGen is nondeterministic)
00373  * @param rPowerStatesPlant
00374  *   Mapping of deterministic states to set of nondeterministic states
00375  * @param rPowerStatesSpec
00376  *   Mapping of deterministic states to set of nondeterministic states
00377  * @param rDetPlantBool
00378  *   true if rPlantGen is deterministic, false if not
00379  * @param rDetSpecBool
00380  *   true if rSpecGen is deterministic, false if not
00381  * @param rResGen
00382  *   Reference to resulting Generator, the
00383  *   minimal restrictive nonblocking supervisor
00384  *
00385  * @exception Exception
00386  *   Alphabets of generators don't match (id 500)
00387  */
00388 void SupConNBNonDet(
00389   const vGenerator& rPlantGen, 
00390   const EventSet&  rCAlph,
00391   const vGenerator& rSpecGen,
00392   std::map< std::pair<Idx,Idx>, Idx>& rReverseCompositionMap,
00393   Generator rDetPlantGen, 
00394   Generator rDetSpecGen, 
00395   std::map<Idx,StateSet>& rPowerStatesPlant, 
00396   std::map<Idx,StateSet>& rPowerStatesSpec,
00397   bool& rDetPlantBool, 
00398   bool& rDetSpecBool, 
00399   vGenerator& rResGen);
00400 
00401 /** 
00402  * Nonblocking Supremal Controllable Sublanguage (internal function)
00403  * 
00404  * This version of SupConNB creates a "reverse composition map" given 
00405  * as reference parameter. It is used by the user function to set up
00406  * descriptive state names of the supervisor.
00407  * 
00408  * @param rPlantGen
00409  *   Plant Generator 
00410  * @param rCAlph
00411  *   Controllable events
00412  * @param rSpecGen
00413  *   Specification Generator 
00414  * @param rReverseCompositionMap
00415  *   std::map< std::pair<Idx,Idx>, Idx> as in the parallel composition function
00416  * @param rResGen
00417  *   Reference to resulting cGenerator, the
00418  *   minimal restrictive nonblocking supervisor
00419  *
00420  * @exception Exception
00421  *   - alphabets of generators don't match (id 100)
00422  *   - plant nondeterministic (id 201)
00423  *   - spec nondeterministic (id 203)
00424  *   - plant and spec nondeterministic (id 204)
00425  */
00426 void SupConNBUnchecked(
00427   const vGenerator& rPlantGen, 
00428   const EventSet&  rCAlph,
00429   const vGenerator& rSpecGen, 
00430   std::map< std::pair<Idx,Idx>,Idx >& rReverseCompositionMap, 
00431   vGenerator& rResGen);
00432 
00433 
00434 
00435 /**
00436  * Supremal Controllable Sublangauge (internal function)
00437  *
00438  * Calls IsControllable to indetify "critical"  states in
00439  * the supervisor candidate. Then deletes critical states
00440  * from the candidate supervisor in order to achieve 
00441  * controllability. 
00442  *
00443  * In general, the result is blocking.
00444  *
00445  * @param rPlantGen
00446  *   Plant generator
00447  * @param rCAlph
00448  *   Controllable events
00449  * @param rSupCandGen
00450  *   Supervisor candidate generator
00451  *
00452  * @return
00453  *   True if no state has been deleted. Else false.
00454  *
00455  */
00456 bool SupConUnchecked(
00457    const vGenerator& rPlantGen, 
00458    const EventSet&  rCAlph,
00459    vGenerator& rSupCandGen);
00460 
00461 
00462 /** 
00463  * Parallel composition optimized for the purpose of SupCon (internal function)
00464  * 
00465  * Composition stops at transition paths that violate the specification
00466  * by uncontrollable plant transitions. 
00467  * 
00468  * @param rPlantGen
00469  *   Plant Generator 
00470  * @param rCAlph
00471  *   Uncontrollable Events
00472  * @param rSpecGen
00473  *   Specification Generator 
00474  * @param rReverseCompositionMap
00475  *   std::map< std::pair<Idx,Idx>, Idx> as in the parallel composition function
00476  * @param rResGen
00477  *   Reference to resulting Generator, the
00478  *   less restrictive supervisor
00479  */
00480 void SupconParallel(
00481   const vGenerator& rPlantGen, 
00482   const EventSet& rCAlph, 
00483   const vGenerator& rSpecGen,
00484   std::map< std::pair<Idx,Idx>, Idx>& rReverseCompositionMap, 
00485   vGenerator& rResGen);
00486 
00487 /**
00488  * Controllability (internal function)
00489  *
00490  * Checks if language of specification h is controllable with respect to
00491  * language of generator g.  Only for deterministic plant + spec. 
00492  *
00493  *
00494  * Controllable event set has to be given as parameter.
00495  * Returns the set of critical states as last parameter.
00496  *
00497  * @param rPlantGen
00498  *   Plant generator
00499  * @param rCAlph
00500  *   Controllable events
00501  * @param rSpecGen
00502  *   Specification generator
00503  * @param rCriticalStates
00504  *   Set of critical states
00505  *
00506  * @exception Exception
00507  *   - alphabets of generators don't match (id 100)
00508  *   - plant generator nondeterministic (id 201)
00509  *   - specification generator nondeterministic (id 203)
00510  *   - plant & spec generator nondeterministic (id 204)
00511  *
00512  * @return 
00513  *   true / false
00514  */
00515 bool IsControllableUnchecked(
00516   const vGenerator& rPlantGen, 
00517   const EventSet& rCAlph, 
00518   const vGenerator& rSpecGen, 
00519   StateSet& rCriticalStates);
00520 
00521 
00522 /**
00523  * Helper function for IsControllable. The state given as "current" is
00524  * considered critical. Itself and all uncontrollable predecessor states 
00525  * are added to the set "rCriticalStates". 
00526  *
00527  * @param rCAlph
00528  *   Set of controllable events
00529  * @param rtransrel
00530  *   Reverse sorted transition relation
00531  * @param rCriticalStates
00532  *   Set of critical states in composition generator
00533  * @param current
00534  *   Current state
00535  */
00536 void TraverseUncontrollableBackwards(
00537   const EventSet& rCAlph, 
00538   TransSetX2EvX1& rtransrel, 
00539   StateSet& rCriticalStates, 
00540   Idx current);
00541 
00542 
00543 
00544 /**
00545  * Consistency check for controlproblem input data.
00546  * Tests whether alphabets match and generators are deterministic.
00547  *
00548  * @param rPlantGen
00549  *   Plant generator
00550  * @param rCAlph
00551  *   Controllable events
00552  * @param rSpecGen
00553  *   Specification generator
00554  *
00555  * @exception Exception
00556  *   - lphabets of generators don't match (id 100)
00557  *   - plant generator nondeterministic (id 201)
00558  *   - specification generator nondeterministic (id 203)
00559  *   - plant and spec generator nondeterministic (id 204)
00560  */
00561 void ControlProblemConsistencyCheck(
00562   const vGenerator& rPlantGen, 
00563   const EventSet&  rCAlph,
00564   const vGenerator& rSpecGen);
00565 
00566 
00567 
00568 
00569 
00570 
00571 
00572 } // namespace faudes
00573 
00574 #endif 
00575 
00576 

libFAUDES 2.14g --- 2009-12-3 --- c++ source docu by doxygen 1.5.6