pd_alg_cc.h
Go to the documentation of this file.
1 /** @file pd_alg_cc.h Top-Level functions*/
2 
3 
4 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes)
5 
6  Copyright (C) 2013 Stefan Jacobi, Sven Schneider, Anne-Kathrin Hess
7 
8 */
9 
10 
11 #ifndef FAUDES_PD_ALG_CC_H
12 #define FAUDES_PD_ALG_CC_H
13 
14 #include "corefaudes.h"
15 #include "pd_pdgenerator.h"
16 #include "pd_alg_lrm.h"
17 #include "pd_alg_lrp.h"
18 #include "pd_alg_nb_sub_a.h"
19 #include "pd_alg_nb_sub_b.h"
20 #include "pd_lang_k.h"
21 #include <sys/time.h>
22 
23 namespace faudes {
24 
25  /**
26  * Get all states that are the starting state of a lambda reading transition
27  *
28  * @param pd
29  * the generator
30  * @return
31  * the states
32  */
34 
35  /**
36  * Remove non-controllable ears from a generator. The initial state must not be an ear.
37  * Times and Split must have been executed on the generator.
38  *
39  * @param pd
40  * the pushdown generator with ears
41  * @param s
42  * the system that was used in the intersection operation to generate the
43  * pushdown generator
44  * @return
45  * pushdowngenerator without noncontrollable ears
46  */
47  PushdownGenerator Rnce(const PushdownGenerator& pd, const System& s);
48 
49  /**
50  * synchronous product generator of a pushdown generator and a regular generator
51  *
52  * @param reg
53  * the regualar generator
54  * @param pd
55  * the pushdown generator
56  * @return
57  * the synchronous product
58  */
59  PushdownGenerator Times(const System& reg, const PushdownGenerator& pd);
60 
61  /**
62  * Adds the intersection of events of the first two generators to the
63  * result generator. The function considers observability and controllability,
64  * so observability and controllability attributes will be kept.
65  *
66  * @param s
67  * first generator
68  * @param pd
69  * second generator
70  * @param rPd
71  * result generator
72  */
73  void IntersectEvents(const System& s, const PushdownGenerator& pd, PushdownGenerator& rPd);
74 
75  /**
76  * Splits the states of a pushdown generator into heads and ears. Each ear is
77  * associated with a stack symbol.
78  *
79  * Transitions will always be either from ear to head or from head to ear.
80  * Transitions from ear to head will always pop the stack symbol associated
81  * with the ear. Transitions from head to ear will always read lambda and
82  * pop and push the stack symbol associated with the ear.
83  *
84  * @param pd
85  * pushdown generator to be split
86  * @return
87  * the split pushdown generator
88  */
90 
91  /**
92  * Make a pushdown generator nonblocking. This will remodel the pushdown generator
93  * and replace stack symbols with new ones.
94  *
95  * @param pd
96  * pushdown generator to make nonblocking
97  * @param res
98  * nonblocking pushdown generator
99  * @param print
100  * temporary debug parameter
101  */
102  void PushdownNonblock(const PushdownGenerator& pd, PushdownGenerator& res, bool print = false);
103 
104  /**
105  * Sets controllability and observability flags for a pushdown generator's events to
106  * the event flags of another pushdown generator
107  *
108  * @param correctPd
109  * pushdown generator with correct flags
110  * @param pd
111  * this generator's event flags will be set to the correctPd's event flags
112  */
113  void CorrectEvents(const PushdownGenerator& correctPd, PushdownGenerator& pd);
114 
115  /**
116  * Test a state for reachability.
117  *
118  * @param pd
119  * the pushdown generator
120  * @param state
121  * the state to test for reachability
122  * @return
123  * true if the state is reachable, else false
124  */
125  bool Ts(const PushdownGenerator& pd, Idx state);
126 
127  /**
128  * Test a transition for reachability.
129  *
130  * @param pd
131  * the pushdown generator
132  * @param trans
133  * the transition to test for reachability
134  * @param pop
135  * the pop of the transitions to test for reachability
136  * @param push
137  * the push of the transitions to test for reachability
138  * @return
139  * true if the transition is reachable, else false
140  */
141  bool Te(const PushdownGenerator& pd, const Transition& trans, const std::vector<Idx>& pop, const std::vector<Idx>& push);
142 
143 
144  bool Ruls1(Idx state, const PushdownGenerator& pd);
145 
146  /**
147  * Remove useless states of a pushdown generator.
148  *
149  * @param pd
150  * the generator, which is required to have passed Split() before
151  * @return
152  * generator that only has useable states.
153  */
155 
156 
157 
158  /**
159  * Construct the accessible part of a pushdown generator
160  *
161  * @param pd
162  * pushdown generator to make accessible
163  * @param res
164  * accessible pushdown generator
165  */
167 
168  /**
169  * Single execution of the loop to construct a minimal restrictive sound controller.
170  * Alphabets of specification and plant are expected to be equal.
171  *
172  * @param contr
173  * the controller candidate
174  * @param plant
175  * the plant
176  * @return
177  * product of controller candidate and plant
178  */
179  PushdownGenerator Ccs(const PushdownGenerator& contr, const System& plant);
180 
181  /**
182  * Looped exectuion of to construct a minimal restrictive sound controller. Alphabets
183  * of specification and plant are expected to be equal.
184  *
185  * @param contr
186  * the controller candidate
187  * @param plant
188  * the plant
189  * @param iteration
190  * number of iterations of ccl
191  * @return
192  * minimal restrictive controller
193  */
194  PushdownGenerator Ccl(const PushdownGenerator& contr, const System& plant, Idx iteration = 0);
195 
196  /**
197  * Construct a minimal restrictive sound controller. Alphabets of specification and
198  * plant are expected to be equal.
199  *
200  * @param spec
201  * the specification
202  * @param plant
203  * the plant
204  * @param res
205  * the result
206  * @return
207  */
208  void PushdownConstructController(const PushdownGenerator& spec, const System& plant, PushdownGenerator& res);
209 
210  /**
211  * from http://www.gnu.org/software/libc/manual/html_node/Elapsed-Time.html
212  * Calculates time difference x - y. For debugging and time measurement.
213  *
214  * @param result
215  * the time difference is stored here
216  * @param x
217  * the time x
218  * @param y
219  * the time y
220  * @return
221  * 1 if x - y is negative, else 0
222  */
223  int timeval_subtract (timeval* result, timeval* x, timeval* y);
224 
225 
226 
227 
228 } // namespace faudes
229 
230 #endif

libFAUDES 2.24g --- 2014.09.15 --- c++ api documentaion by doxygen