pd_controllable_test.cpp
Go to the documentation of this file.
1 /** @file pd_controllable_test.cpp
2 
3  This file tests the algorithm to ensure
4  the controllability of a controller.
5 
6 
7  @ingroup Tutorials
8 
9  @include pd_controllable_test.cpp
10 
11  */
12 
13 #include "libfaudes.h"
14 #include "pd_include.h"
15 
16 // make the faudes namespace available to our program
17 using namespace faudes;
18 
19 /**
20  * Tests the algorithm to ensure controllability.
21  * In this case the algorithm is adapted to the given pushdown generator (pd_ctest_contr)
22  * and system (pd_ctest_plant)
23  * General algorithm see ConstructControllerLoop() in file pd_alg_main.cpp
24  */
26 
27  //generator to return
29 
30  //create product generator
31  rPd = Times(sys, cont);
32  FAUDES_TEST_DUMP("product generator", rPd);
33 
34  //trim the generator
35  PushdownTrim(rPd, 0);
36  FAUDES_TEST_DUMP("trim generator", rPd);
37 
38  //split states into heads and ears
39  rPd = Split(rPd);
40  FAUDES_TEST_DUMP("split generator", rPd);
41 
42  //remove inaccessible states
43  PushdownAccessible(rPd,rPd);
44  FAUDES_TEST_DUMP("remove inaccessible states", rPd);
45 
46  //save number of states
47  uint numberOfStates = rPd.Size();
48 
49  //set lambda event controllable
51 
52  //remove non-controllable ears
53  rPd = Rnce(rPd, sys);
54 
55  FAUDES_TEST_DUMP("remove non-controllable ears", rPd);
56 
57  FAUDES_TEST_DUMP("states before > states now", numberOfStates > rPd.Size());
58 
59  return rPd;
60 }
61 
62 /** Run the blockfree test */
63 int main() {
64 
65  //*******************************
66  //Get pushdown generator from DOT-file
67  //The generator and plant can be seen in
68  //data/graph/pd_ctest_contr.png and data/graph/pd_ctest_plant.png
69  //State 's2' will prevent the uncontrollable event 'u'
70  //*******************************
71  PushdownGenerator cont("data/graph/pd_ctest_contr.dot");
72  System plant = SystemFromDot("data/graph/pd_ctest_plant.dot");
73 
74  //*******************************
75  //create controllable generator
76  //*******************************
78  rPd = make_controllable(cont, plant);
79 
80  //*******************************
81  // Record test case
82  //*******************************
83 
84  FAUDES_TEST_DUMP("plant", plant);
85  FAUDES_TEST_DUMP("controller with controllability problems", plant);
86  FAUDES_TEST_DUMP("controllable controller", rPd);
87 
88  // Validate result
90 
91  // done
92  return 0;
93 }
94 

libFAUDES 2.26g --- 2015.08.17 --- c++ api documentaion by doxygen