pd_example_WODES14_nonblock.cpp
Go to the documentation of this file.
1 /** @file pd_example_WODES14_nonblock
2 
3 Makes an example DPDA nonblocking. This example is taken from the paper by Schneider and Nestman submitted to WODES'14, discussing the nonblock-algorithm implemented here.
4 
5 // To save output to file and display it in shell, use
6 // "./pd_example_WODES14_nonblock ls -l 2>&1 | tee pd_example_WODES14_nonblock.txt"
7 
8 @ingroup Tutorials
9 
10 @include pd_example_WODES14_nonblock.cpp
11 
12 */
13 
14 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes)
15 
16  Copyright (C) 2013 Sven Schneider,Anne-Kathrin Schmuck,Stefan Jacobi
17 
18 */
19 
20 #include "libfaudes.h"
21 #include "pd_include.h"
22 
23 // make the faudes namespace available to our program
24 using namespace faudes;
25 
26 int main(){
27 
28  //*****************************************************
29  //create the input DPDA by using a pushdown generator
30  //****************************************************
32 
33  //insert states
34  g.InsState("q0");
35  g.InsState("q1");
36  g.InsState("q2");
37  g.InsState("q3");
38  g.InsState("q4");
39 
40  //insert stack symbols
41  Idx lambda = g.InsStackSymbol(FAUDES_PD_LAMBDA); //always use FAUDES_PD_LAMBDA for lambda!
42  Idx dot = g.InsStackSymbol("dot");
43  Idx square = g.SetStackBottom("square");
44 
45  //insert events
46  g.InsControllableEvent("a");
47  g.InsControllableEvent("b");
48  g.InsControllableEvent("d");
49  g.InsEvent(FAUDES_PD_LAMBDA); //always use FAUDES_PD_LAMBDA for lambda-transitions!
50 
51  //build stack symbol vectors to be inserted as pop and push attributes of transitions
52  std::vector<Idx> vLambda; //vLambda is the abbreviation for the empty string
53  vLambda.push_back(lambda);
54 
55  std::vector<Idx> vSquare; //vSquare is the abbreviation for the string "Box"
56  vSquare.push_back(square);
57 
58  std::vector<Idx> vDot; //vDot is the abbreviation for the string "Dot"
59  vDot.push_back(dot);
60 
61  std::vector<Idx> vDotSquare; // vDotSquare is the abbreviation for the string "Dot Box"
62  vDotSquare.push_back(dot); // here the dot is pushed AFTER (popped BEFORE) the Box
63  vDotSquare.push_back(square);
64 
65  std::vector<Idx> vDotDot; // vDotDot is the abbreviation for the string "Dot Dot"
66  vDotDot.push_back(dot); // here two dots are pushed (or popped)
67  vDotDot.push_back(dot);
68 
69  //insert transitions
70  g.SetTransition("q0", "a", "q0",vSquare,vDotSquare);
71  g.SetTransition("q0", "a", "q0",vDot,vDotDot);
72  g.SetTransition("q0", "b", "q1",vDot,vDot);
73  g.SetTransition("q0", "b", "q1",vSquare,vSquare);
74  g.SetTransition("q1", "b", "q2",vDot,vLambda);
75  g.SetTransition("q2", "d", "q1",vDot,vLambda);
76  g.SetTransition("q2", FAUDES_PD_LAMBDA , "q2",vSquare,vSquare);
77  g.SetTransition("q1", FAUDES_PD_LAMBDA , "q3",vSquare,vDotSquare);
78  g.SetTransition("q3", FAUDES_PD_LAMBDA , "q1",vSquare,vDotSquare);
79  g.SetTransition("q3", "a", "q4",vSquare,vSquare);
80 
81  //set state attributes
82  g.SetInitState("q0"); // one initial state
83  g.SetMarkedState("q3");
84  g.SetMarkedState("q4");
85 
86  //*******************************
87  //print the DPDA
88  //*******************************
89  g.Write();
90 
91  //*******************************
92  //call blockfree algorithm
93  //*******************************
95  PushdownNonblock(g,rPd);
96 
97  //*******************************
98  //print resulting DPDA
99  //*******************************
100  std::cout << "***************** RESULT *****************" << std::endl;
101  rPd.Write();
102 
103  //*******************************
104  //print words that are possible in the closed loop
105  //*******************************
106  LangK test(rPd);
107  test.FindLangK(50);
108  test.PrintWords();
109 
110  return 0;
111 }
112 

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