mtc_redundantcolors.h
Go to the documentation of this file.
1 /** @file mtc_redundantcolors.h
2 
3 Methods for removing redundant colors for the supervisor synthesis from MtcSystems
4 
5 */
6 
7 /* FAU Discrete Event Systems Library (libfaudes)
8 
9  Copyright (C) 2008 Matthias Singer
10  Copyright (C) 2006 Bernd Opitz
11  Exclusive copyright is granted to Klaus Schmidt
12 
13  This library is free software; you can redistribute it and/or
14  modify it under the terms of the GNU Lesser General Public
15  License as published by the Free Software Foundation; either
16  version 2.1 of the License, or (at your option) any later version.
17 
18  This library is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  Lesser General Public License for more details.
22 
23  You should have received a copy of the GNU Lesser General Public
24  License along with this library; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26 
27 
28 #ifndef FAUDES_MTCREDUNDANTCOLORS_H
29 #define FAUDES_MTCREDUNDANTCOLORS_H
30 
31 #include "corefaudes.h"
33 
34 namespace faudes {
35 
36  /**
37  * Search for strongly connected components (SCC)***
38  * This function partitions the stateset of a generator into equivalence classes
39  * such that states x1 and x2 are equivalent iff there is a path from x1
40  * to x2 AND a path from x2 to x1.
41  * This function implements the algorithm based on a depth first search
42  * presented in:
43  * -Aho, Hopcroft, Ullman: The Design and Analysis of Computer Algorithms-
44  *
45  * Most of the comments in this function have been literally taken from
46  * this book!
47  *
48  * @param state
49  * State, from which the current recursion is started.
50  * @param rCount
51  * denotes the current depth of the recursion.
52  * @param rGen
53  * Generator under investigation
54  * @param rNewStates
55  * Set of states that up to now were not found by the depth first search
56  * @param rSTACK
57  * stack of state indices
58  * @param rStackStates
59  * set of states whose indices are on STACK.
60  * @param rDFN
61  * map assigning to each state its Depth-First Number
62  * @param rLOWLINK
63  * map assigning to each state its LOWLINK Number
64  * @param rSccSet
65  * result - the set of strongly connected components
66  * @param rRoots:
67  * result - the set of states that each are root of some SCC.
68  */
69 extern FAUDES_API void SearchScc( const Idx state, int& rCount, const Generator& rGen, StateSet& rNewStates,
70  std::stack<Idx>& rSTACK, StateSet& rStackStates, std::map<const Idx, int>& rDFN,
71  std::map<const Idx, int>& rLOWLINK, std::set<StateSet>& rSccSet, StateSet& rRoots);
72 
73 /**
74  * Computes the strongly connected components (SCCs) of an automaton.
75  * This function is the wrapper function for Trajan's algorithm that is implemented
76  * in the function SearchSCC.
77  *
78  * @param rGen
79  * investigated generator
80  * @param rSccSet
81  * Set of strongly connected components (result).
82  * @param rRoots
83  * Set of states that each are root of some SCC (result).
84  *
85  * @return
86  * true if SCCs have been found, false if not.
87  *
88  * @ingroup MultitaskingPlugin
89  *
90  */
91 extern FAUDES_API bool ComputeSCC(const Generator& rGen, std::set<StateSet>& rSccSet, StateSet& rRoots);
92 
93 /**
94  * Compute all strongly connected components (SCCs) in a colored marking generator (CMG) that are marked with a given set of colors.
95  * This function finds all SCCs in a CMG that contain states with all colors in a given color set.
96  * To find all SCCs, first the function ComputeSCC is called.
97  *
98  * @param rGen
99  * generator under investigation
100  * @param rColors
101  * colors that have to be contained in the SCCs
102  * @param rColoredSCCs
103  * SCCs marked with all colors in rColors
104  *
105  * @ingroup MultitaskingPlugin
106  */
107 extern FAUDES_API void ColoredSCC(MtcSystem& rGen, ColorSet& rColors, std::set<StateSet>& rColoredSCCs);
108 
109 /**
110  * Check if a color in a colored marking generator is redundant for the supervisor synthesis.
111  * This function determines if a color can be removed from a CMG if it is redundant for
112  * the supervisor synthesis. The algorithm implements the work in
113  * K. Schmidt and J.E.R. Cury, "Redundant Colors in the Multitasking Supervisory Control for Discrete
114  * Event Systems", Workshop on Dependable Control of Discrete Event Systems, 2009.
115  *
116  * @param rGen
117  * Reference to generator
118  * @param redundantColor
119  * Index of the color to be removed
120  + @return
121  * true if the color can be removed, false otherwise
122  *
123  *
124  * @ingroup MultitaskingPlugin
125  */
126 extern FAUDES_API bool CheckRedundantColor(MtcSystem rGen, Idx redundantColor);
127 
128 
129  /**
130  * Compute an optimal subset of the colors that should be removed.
131  * This function tries to find an optimal subset of colors that can be removed from the given
132  * colored marking generator without affecting supervisor synthesis. Here, optimality is defined
133  * w.r.t. the smallest number of states of a high-level generator after removing the colors.
134  *
135  * @param rGen
136  * input colored marking generator
137  * @param rOptimalColors
138  * optimal color set to be removed
139  * @param rHighAlph
140  * hgh-level alphabet for hierarchical abstraction after color removal. Initially, the alphabet should contain
141  * all events that must be present in the high-level alphabet
142  *
143  *
144  * @ingroup MultitaskingPlugin
145  */
146 extern FAUDES_API void OptimalColorSet(const MtcSystem& rGen, ColorSet& rOptimalColors, EventSet& rHighAlph);
147 
148 /**
149  * Recursively find an optimal set of colors to be removed.
150  * This function recursively enumerates all possible subsets of colors that can be removed without affecting
151  * supervisor synthesis and remembers the color set that leads to the smallest hierarchical abstraction.
152  * It is called by the function OptimalColorSet.
153  *
154  * @param rGen
155  * input colored marking generator
156  * @param rColorVector
157  * set of colors of the generator (ordered!)
158  * @param colorNumber
159  * number of colors currently removed
160  * @param rOptimalColors
161  * current optimal set of colors
162  * @param rOptimalNumberStates
163  * current optimal number of states
164  * @param rOptimalNumberColors
165  * size of the optimal color set
166  * @param rHighAlph
167  * initial high-level alphabet
168  * @param rOptimalHighAlph
169  * optimal high-level alphabet
170  *
171  */
172 extern FAUDES_API void rec_OptimalColorSet(const MtcSystem& rGen, const std::vector<Idx>& rColorVector, Idx colorNumber, ColorSet& rOptimalColors,
173  Idx& rOptimalNumberStates, Idx& rOptimalNumberColors, const EventSet& rHighAlph, EventSet& rOptimalHighAlph);
174 } // namespace faudes
175 
176 #endif
#define FAUDES_API
Interface export/import symbols: windows.
Definition: cfl_platform.h:81
Includes all libFAUDES headers, no plugins.
IndexSet StateSet
Definition: cfl_indexset.h:271
NameSet EventSet
Convenience typedef for plain event sets.
Definition: cfl_nameset.h:531
vGenerator Generator
Plain generator, api typedef for generator with no attributes.
void OptimalColorSet(const MtcSystem &rGen, ColorSet &rOptimalColors, EventSet &rHighAlph)
Compute an optimal subset of the colors that should be removed.
void ColoredSCC(MtcSystem &rGen, ColorSet &rColors, std::set< StateSet > &rColoredSCCs)
Compute all strongly connected components (SCCs) in a colored marking generator (CMG) that are marked...
bool ComputeSCC(const Generator &rGen, std::set< StateSet > &rSCCSet, StateSet &rRoots)
Computes the strongly connected components (SCCs) of an automaton.
bool CheckRedundantColor(MtcSystem rGen, Idx redundantColor)
Check if a color in a colored marking generator is redundant for the supervisor synthesis.
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
void rec_OptimalColorSet(const MtcSystem &rGen, const std::vector< Idx > &rColorVector, Idx colorNumber, ColorSet &rOptimalColors, Idx &rOptimalNumberStates, Idx &rOptimalNumberColors, const EventSet &rHighAlph, EventSet &rOptimalHighAlph)
Recursively find an optimal set of colors to be removed.
TmtcGenerator< AttributeVoid, AttributeColoredState, AttributeCFlags, AttributeVoid > MtcSystem
void SearchScc(const Idx vState, int &vRcount, const Generator &rGen, const SccFilter &rFilter, StateSet &rTodo, std::stack< Idx > &rStack, StateSet &rStackStates, std::map< const Idx, int > &rDfn, std::map< const Idx, int > &rLowLnk, std::list< StateSet > &rSccList, StateSet &rRoots)
Search for strongly connected components (SCC).

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen