pd_tutorial.cpp
Go to the documentation of this file.
1 /** @file pd_tutorial.cpp
2 
3 Tutorial, pushdown plugin.
4 @ingroup Tutorials
5 
6 @include pd_tutorial.cpp
7 
8 */
9 
10 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes)
11 
12  Copyright (C) 2013 Stefan Jacobi, Sven Schneider, Anne-Kathrin Hess
13 
14 */
15 
16 #include "libfaudes.h"
17 #include "pd_include.h"
18 
19 // make the faudes namespace available to our program
20 using namespace faudes;
21 
22 int main(){
23 
24  //*******************************
25  //create the specification, a pushdown generator
26  //*******************************
28 
29  //insert states
30  g.InsState("s1");
31  g.InsState("s2");
32  g.InsState("s3");
33 
34  //insert stack symbols
35  Idx lambda = g.InsStackSymbol(FAUDES_PD_LAMBDA); //always use FAUDES_PD_LAMBDA for empty stack symbol!
36  Idx dot = g.InsStackSymbol("dot");
37  Idx square = g.SetStackBottom("square");
38 
39  //insert events
40  g.InsControllableEvent("a");
41  g.InsEvent("b");
42  g.InsUncontrollableEvent(FAUDES_PD_LAMBDA); //always use FAUDES_PD_LAMBDA for empty event!
43 
44  //build stack symbol vectors to be inserted as pop and push attributes of transitions
45  std::vector<Idx> vLambda;
46  vLambda.push_back(lambda);
47  std::vector<Idx> vSquare;
48  vSquare.push_back(square);
49  std::vector<Idx> vDot;
50  vDot.push_back(dot);
51  std::vector<Idx> vDotSquare;
52  vDotSquare.push_back(dot);
53  vDotSquare.push_back(square);
54 
55  //insert transitions
56  g.SetTransition("s1", "a", "s2",vSquare,vDotSquare);
57  g.SetTransition("s2", "b", "s3",vDot,vDot);
58 
59  //set state attributes
60  g.SetInitState("s1");
61  g.SetMarkedState("s1");
62  g.SetMarkedState("s2");
63  g.SetMarkedState("s3");
64 
65  //*******************************
66  //create the plant, a DFA
67  //*******************************
68  System s;
69 
70  s.InsState("s1");
71  s.InsState("s2");
72  s.InsState("s3");
73 
74  s.InsControllableEvent("a");
75  s.InsEvent("b");
76 
77  s.SetTransition("s1", "a", "s1");
78  s.SetTransition("s1", "a", "s2");
79  s.SetTransition("s2", "b", "s3");
80 
81  s.SetInitState("s1");
82  s.SetMarkedState("s3");
83 
84  //*******************************
85  //print plant and specification
86  //*******************************
87  g.Write();
88  s.Write();
89 
90  //*******************************
91  //call synthesis algorithm
92  //*******************************
95 
96  //*******************************
97  //print result
98  //*******************************
99  std::cout << "***************** RESULT *****************" << std::endl;
100  rPd.Write();
101 
102  //*******************************
103  //print words that are possible in the closed loop (only "ab" expected)
104  //*******************************
105  LangK test(rPd);
106  test.FindLangK(50);
107  test.PrintWords();
108 
109  return 0;
110 }
111 

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