pd_alg_main.h
Go to the documentation of this file.
1 /** @file pd_alg_main.h Top-Level functions*/
2 
3 
4 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes)
5 
6  Copyright (C) 2013/14 Ramon Barakat, Stefan Jacobi, Sven Schneider, Anne-Kathrin Hess
7 
8 */
9 
10 
11 #ifndef FAUDES_PD_ALG_MAIN_H
12 #define FAUDES_PD_ALG_MAIN_H
13 
14 #include "corefaudes.h"
15 #include "pd_pdgenerator.h"
16 #include "pd_alg_sub.h"
17 
18 #include "pd_debug.h"
19 #include "pd_scopelogger.h"
20 
21 namespace faudes {
22 
23 /**
24  * Construct a minimal restrictive sound controller, based on the Algorithm presented by
25  * Sven Schneider and Anne-Kathrin Schmuck.
26  *
27  * Alphabets of specification and plant are expected to be equal.
28  *
29  * @param spec
30  * Reference to specification
31  * @param plant
32  * Reference to plant
33  * @param rRes
34  * Reference to resulting minimal restrictive controller
35  * @param debug
36  * Set true, to print out single steps of the function
37  *
38  * @return
39  */
40 extern FAUDES_API void PushdownConstructController(const PushdownGenerator& rSpec,const System& rPlant, PushdownGenerator& rRes, bool debug = false);
41 
42 /**
43  * Create a nonblocking product generator of a pushdown generator and a regular generator.
44  * For that, ConstructControllerPreCombine(...) will create the product generator and call the
45  * PushdownBlockfree(...) function.
46  *
47  * @param rSpec
48  * Reference to pushdown generator
49  * @param rPlant
50  * Reference to regular generator
51  * @param rRes
52  * Reference to resulting nonblocking product generator
53  * @param debug
54  * Set true, to print out single steps of the function
55  *
56  * @return
57  */
58 extern FAUDES_API void ConstructControllerPreCombine(const PushdownGenerator& rSpec, const System& rPlant, PushdownGenerator& rRes, bool debug = false);
59 
60 /**
61  * Looped execution to construct a minimal restrictive controller.
62  * Alphabets of specification and plant are expected to be equal.
63  *
64  * @param rContr
65  * Reference to controller candidate
66  * @param rPlant
67  * Reference to plant
68  * @param rRes
69  * Reference to resulting minimal restrictive controller
70  * @param loopcounter
71  * Number to count number of iterations
72  * @param debug
73  * Set true, to print out single steps of the function
74  *
75  * @return
76  * number of iterations of ConstructControllerLoop
77  */
78 extern FAUDES_API int ConstructControllerLoop(const PushdownGenerator& rContr, const System& rPlant, PushdownGenerator& rRes, int loopcounter = 0, bool debug = false);
79 
80 /**
81  * Make a pushdown generator nonblocking.
82  * This means, that the function will solve blocking issues.
83  *
84  * Technical Details:
85  * The Algorithm converts the given pushdown generator to a (LR(1)-) grammar,
86  * removes unreachable productions and reconverts the grammar (via LR-parser) to an automaton.
87  * This will remodel the pushdown generator and may replace states and stack symbols with new ones.
88  *
89  * The marked language does not change
90  *
91  * @param rPd
92  * Reference to pushdown generator to make nonblocking
93  * @param rResPd
94  * Reference to resulting nonblocking pushdown generator
95  * @param debug
96  * Set true, to print out single steps of the function
97  *
98  * @return
99  */
100 extern FAUDES_API void PushdownBlockfree(const PushdownGenerator& rPd, PushdownGenerator& rResPd, bool debug = false);
101 
102 
103 /**
104  * Construct the accessible part of a pushdown generator
105  *
106  * Technical Details:
107  * The Algorithm converts the given pushdown generator to a context free grammar (CFG) and
108  * removes unreachable productions. From the reduced CFG accessible states and transitions can be identified.
109  *
110  * By creating only reducible productions (see Sp2Lr() ) the function will also remove not coaccessible states.
111  * To avoid this, set 'coacc' to false.
112  *
113  * @param rPd
114  * Reference to pushdown generator to make accessible
115  * @param resPd
116  * Reference to resulting accessible pushdown generator
117  * @param coacc
118  * Set false, to avoid that not coaccessible states will be removed
119  * @param debug
120  * Set true, to print out single steps of the function.
121  *
122  * @return
123  */
124 extern FAUDES_API void PushdownAccessible(const PushdownGenerator& pd, PushdownGenerator& resPd, bool coacc = true, bool debug = false);
125 
126 
127 /**
128  * Get all states that are the starting state of a lambda reading transition
129  *
130  * @param pd
131  * the generator
132  * @return
133  * the states
134  */
136 
137 /**
138  * Remove non-controllable ears from a generator. The initial state must not be an ear.
139  * Times and Split must have been executed on the generator.
140  *
141  * @param pd
142  * the pushdown generator with ears
143  * @param s
144  * the system that was used in the intersection operation to generate the
145  * pushdown generator
146  * @return
147  * pushdowngenerator without noncontrollable ears
148  */
149 extern FAUDES_API PushdownGenerator Rnce(const PushdownGenerator& pd, const System& s);
150 
151 /**
152  * synchronous product generator of a pushdown generator and a regular generator
153  *
154  * @param reg
155  * the regualar generator
156  * @param pd
157  * the pushdown generator
158  * @return
159  * the synchronous product
160  */
161 extern FAUDES_API PushdownGenerator Times(const System& reg, const PushdownGenerator& pd);
162 
163 /**
164  * Adds the intersection of events of the first two generators to the
165  * result generator. The function considers observability and controllability,
166  * so observability and controllability attributes will be kept.
167  *
168  * @param s
169  * first generator
170  * @param pd
171  * second generator
172  * @param rPd
173  * result generator
174  */
175 extern FAUDES_API void IntersectEvents(const System& s, const PushdownGenerator& pd, PushdownGenerator& rPd);
176 
177 /**
178  * Splits the states of a pushdown generator into heads and ears. Each ear is
179  * associated with a stack symbol.
180  *
181  * Transitions will always be either from ear to head or from head to ear.
182  * Transitions from ear to head will always pop the stack symbol associated
183  * with the ear. Transitions from head to ear will always read lambda and
184  * pop and push the stack symbol associated with the ear.
185  *
186  * @param pd
187  * pushdown generator to be split
188  * @return
189  * the split pushdown generator
190  */
192 
193 
194 
195 /**
196  * Sets controllability and observability flags for a pushdown generator's events to
197  * the event flags of another pushdown generator
198  *
199  * @param correctPd
200  * pushdown generator with correct flags
201  * @param pd
202  * this generator's event flags will be set to the correctPd's event flags
203  */
204 extern FAUDES_API void CorrectEvents(const PushdownGenerator& correctPd, PushdownGenerator& pd);
205 
206 
207 /**
208  * from http://www.gnu.org/software/libc/manual/html_node/Elapsed-Time.html
209  * Calculates time difference x - y. For debugging and time measurement.
210  *
211  * @param result
212  * the time difference is stored here
213  * @param x
214  * the time x
215  * @param y
216  * the time y
217  * @return
218  * 1 if x - y is negative, else 0
219  */
220 int timeval_subtract (timeval* result, timeval* x, timeval* y);
221 
222 
223 
224 
225 
226 } // namespace faudes
227 
228 #endif

libFAUDES 2.28c --- 2016.09.30 --- c++ api documentaion by doxygen