mtc_redundantcolors.h

Go to the documentation of this file.
00001 /** @file mtc_redundantcolors.h
00002 
00003 Methods for removing redundant colors for the supervisor synthesis from MtcSystems
00004 
00005 */
00006 
00007 /* FAU Discrete Event Systems Library (libfaudes)
00008 
00009    Copyright (C) 2008  Matthias Singer
00010    Copyright (C) 2006  Bernd Opitz
00011    Exclusive copyright is granted to Klaus Schmidt
00012 
00013    This library is free software; you can redistribute it and/or
00014    modify it under the terms of the GNU Lesser General Public
00015    License as published by the Free Software Foundation; either
00016    version 2.1 of the License, or (at your option) any later version.
00017 
00018    This library is distributed in the hope that it will be useful,
00019    but WITHOUT ANY WARRANTY; without even the implied warranty of
00020    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021    Lesser General Public License for more details.
00022 
00023    You should have received a copy of the GNU Lesser General Public
00024    License along with this library; if not, write to the Free Software
00025    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00026 
00027 
00028 #ifndef FAUDES_MTCREDUNDANTCOLORS_H
00029 #define FAUDES_MTCREDUNDANTCOLORS_H
00030 
00031 #include "corefaudes.h"
00032 #include "mtc_observercomputation.h"
00033 
00034 namespace faudes {
00035 
00036    /** 
00037    * Search for strongly connected components (SCC)***
00038    * This function partitions the stateset of a generator into equivalence classes
00039    * such that states x1 and x2 are equivalent iff there is a path from x1
00040    * to x2 AND a path from x2 to x1.
00041    * This function implements the algorithm based on a depth first search
00042    * presented in:
00043    * -Aho, Hopcroft, Ullman: The Design and Analysis of Computer Algorithms-
00044    *
00045    * Most of the comments in this function have been literally taken from
00046    * this book!
00047    *
00048    * @param state
00049    *    State, from which the current recursion is started.
00050    * @param rCount
00051    *   denotes the current depth of the recursion.
00052    * @param rGen
00053    *   Generator under investigation
00054    * @param rNewStates 
00055    *   Set of states that up to now were not found by the depth first search
00056    * @param rSTACK
00057    *    stack of state indices
00058    * @param rStackStates
00059    *    set of states whose indices are on STACK.
00060    * @param rDFN
00061    *    map assigning to each state its Depth-First Number
00062    * @param rLOWLINK
00063    *    map assigning to each state its LOWLINK Number
00064    * @param rSccSet
00065    *    result - the set of strongly connected components
00066    * @param rRoots: 
00067    *   result - the set of states that each are root of some SCC.
00068    */
00069 void SearchScc( const Idx state, int& rCount,  const Generator& rGen, StateSet&  rNewStates,
00070   std::stack<Idx>& rSTACK, StateSet& rStackStates, std::map<const Idx, int>& rDFN,
00071   std::map<const Idx, int>& rLOWLINK, std::set<StateSet>& rSccSet, StateSet& rRoots);
00072 
00073 /**
00074  * Computes the strongly connected components (SCCs) of an automaton.
00075  * This function is the wrapper function for Trajan's algorithm that is implemented
00076  * in the function SearchSCC. 
00077  * 
00078  * @param rGen
00079  *   investigated generator
00080  * @param rSccSet
00081  *   Set of strongly connected components (result).
00082  * @param rRoots
00083  *   Set of states that each are root of some SCC (result).
00084  *
00085  * @return
00086  *   true if SCCs have been found, false if not.
00087  * 
00088  * @ingroup MultitaskingPlugin 
00089  *
00090  */
00091 bool ComputeSCC(const Generator& rGen, std::set<StateSet>& rSccSet, StateSet& rRoots); 
00092 
00093 /**
00094  * Compute all strongly connected components (SCCs) in a colored marking generator (CMG) that are marked with a given set of colors. 
00095  * This function finds all SCCs in a CMG that contain states with all colors in a given color set.
00096  * To find all SCCs, first the function ComputeSCC is called. 
00097  *
00098  * @param rGen
00099  *  generator under investigation
00100  * @param rColors
00101  *  colors that have to be contained in the SCCs
00102  * @param rColoredSCCs
00103  *  SCCs marked with all colors in rColors
00104  * 
00105  * @ingroup MultitaskingPlugin 
00106  */
00107 void ColoredSCC(MtcSystem& rGen, ColorSet& rColors, std::set<StateSet>& rColoredSCCs);
00108 
00109 /**
00110  * Check if a color in a colored marking generator is redundant for the supervisor synthesis.
00111  * This function determines if a color can be removed from a CMG if it is redundant for 
00112  * the supervisor synthesis. The algorithm implements the work in 
00113  * K. Schmidt and J.E.R. Cury, "Redundant Colors in the Multitasking Supervisory Control for Discrete
00114  * Event Systems", Workshop on Dependable Control of Discrete Event Systems, 2009.  
00115  *
00116  * @param rGen
00117  *   Reference to generator
00118  * @param redundantColor
00119  *   Index of the color to be removed
00120  + @return 
00121  *   true if the color can be removed, false otherwise
00122  *
00123  * 
00124  * @ingroup MultitaskingPlugin 
00125  */
00126 bool CheckRedundantColor(MtcSystem rGen, Idx redundantColor);
00127 
00128 
00129  /** 
00130    * Compute an optimal subset of the colors that should be removed.
00131    * This function tries to find an optimal subset of colors that can be removed from the given
00132    * colored marking generator without affecting supervisor synthesis. Here, optimality is defined
00133    * w.r.t. the smallest number of states of a high-level generator after removing the colors. 
00134    *
00135    * @param rGen
00136    *   input colored marking generator
00137    * @param rOptimalColors
00138    *   optimal color set to be removed
00139    * @param rHighAlph
00140    *    hgh-level alphabet for hierarchical abstraction after color removal. Initially, the alphabet should contain
00141    *   all events that must be present in the high-level alphabet
00142    *
00143    *
00144    * @ingroup MultitaskingPlugin    
00145    */
00146 void OptimalColorSet(const MtcSystem& rGen, ColorSet& rOptimalColors, EventSet& rHighAlph);
00147 
00148 /**
00149  * Recursively find an optimal set of colors to be removed.
00150  * This function recursively enumerates all possible subsets of colors that can be removed without affecting
00151  * supervisor synthesis and remembers the color set that leads to the smallest hierarchical abstraction. 
00152  * It is called by the function OptimalColorSet.
00153  *
00154  * @param rGen
00155  *  input colored marking generator
00156  * @param rColorVector
00157  *  set of colors of the generator (ordered!)
00158  * @param colorNumber
00159  *  number of colors currently removed
00160  * @param rOptimalColors
00161  *  current optimal set of colors
00162  * @param rOptimalNumberStates
00163  *  current optimal number of states
00164  * @param rOptimalNumberColors
00165  *  size of the optimal color set
00166  * @param rHighAlph
00167  *  initial high-level alphabet
00168  * @param rOptimalHighAlph
00169  *  optimal high-level alphabet
00170  *
00171  */
00172  void rec_OptimalColorSet(const MtcSystem& rGen, const std::vector<Idx>& rColorVector, Idx colorNumber, ColorSet& rOptimalColors, 
00173         Idx& rOptimalNumberStates, Idx& rOptimalNumberColors, const EventSet& rHighAlph, EventSet& rOptimalHighAlph);
00174 } // namespace faudes
00175 
00176 #endif

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