pd_example_WODES14_nonblock.cppGo to the documentation of this file.00001 /** @file pd_example_WODES14_nonblock 00002 00003 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. 00004 00005 // To save output to file and display it in shell, use 00006 // "./pd_example_WODES14_nonblock ls -l 2>&1 | tee pd_example_WODES14_nonblock.txt" 00007 00008 @ingroup Tutorials 00009 00010 @include pd_example_WODES14_nonblock.cpp 00011 00012 */ 00013 00014 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes) 00015 00016 Copyright (C) 2013 Sven Schneider,Anne-Kathrin Schmuck,Stefan Jacobi 00017 00018 */ 00019 00020 #include "libfaudes.h" 00021 #include "pd_include.h" 00022 00023 // make the faudes namespace available to our program 00024 using namespace faudes; 00025 00026 int main(){ 00027 00028 //***************************************************** 00029 //create the input DPDA by using a pushdown generator 00030 //**************************************************** 00031 PushdownGenerator g; 00032 00033 //insert states 00034 g.InsState("q0"); 00035 g.InsState("q1"); 00036 g.InsState("q2"); 00037 g.InsState("q3"); 00038 g.InsState("q4"); 00039 00040 //insert stack symbols 00041 Idx lambda = g.InsStackSymbol(FAUDES_PD_LAMBDA); //always use FAUDES_PD_LAMBDA for lambda! 00042 Idx dot = g.InsStackSymbol("dot"); 00043 Idx square = g.SetStackBottom("square"); 00044 00045 //insert events 00046 g.InsControllableEvent("a"); 00047 g.InsControllableEvent("b"); 00048 g.InsControllableEvent("d"); 00049 g.InsEvent(FAUDES_PD_LAMBDA); //always use FAUDES_PD_LAMBDA for lambda-transitions! 00050 00051 //build stack symbol vectors to be inserted as pop and push attributes of transitions 00052 std::vector<Idx> vLambda; //vLambda is the abbreviation for the empty string 00053 vLambda.push_back(lambda); 00054 00055 std::vector<Idx> vSquare; //vSquare is the abbreviation for the string "Box" 00056 vSquare.push_back(square); 00057 00058 std::vector<Idx> vDot; //vDot is the abbreviation for the string "Dot" 00059 vDot.push_back(dot); 00060 00061 std::vector<Idx> vDotSquare; // vDotSquare is the abbreviation for the string "Dot Box" 00062 vDotSquare.push_back(dot); // here the dot is pushed AFTER (popped BEFORE) the Box 00063 vDotSquare.push_back(square); 00064 00065 std::vector<Idx> vDotDot; // vDotDot is the abbreviation for the string "Dot Dot" 00066 vDotDot.push_back(dot); // here two dots are pushed (or popped) 00067 vDotDot.push_back(dot); 00068 00069 //insert transitions 00070 g.SetTransition("q0", "a", "q0",vSquare,vDotSquare); 00071 g.SetTransition("q0", "a", "q0",vDot,vDotDot); 00072 g.SetTransition("q0", "b", "q1",vDot,vDot); 00073 g.SetTransition("q0", "b", "q1",vSquare,vSquare); 00074 g.SetTransition("q1", "b", "q2",vDot,vLambda); 00075 g.SetTransition("q2", "d", "q1",vDot,vLambda); 00076 g.SetTransition("q2", FAUDES_PD_LAMBDA , "q2",vSquare,vSquare); 00077 g.SetTransition("q1", FAUDES_PD_LAMBDA , "q3",vSquare,vDotSquare); 00078 g.SetTransition("q3", FAUDES_PD_LAMBDA , "q1",vSquare,vDotSquare); 00079 g.SetTransition("q3", "a", "q4",vSquare,vSquare); 00080 00081 //set state attributes 00082 g.SetInitState("q0"); // one initial state 00083 g.SetMarkedState("q3"); 00084 g.SetMarkedState("q4"); 00085 00086 //******************************* 00087 //print the DPDA 00088 //******************************* 00089 g.Write(); 00090 00091 //******************************* 00092 //call blockfree algorithm 00093 //******************************* 00094 PushdownGenerator rPd; 00095 PushdownNonblock(g,rPd); 00096 00097 //******************************* 00098 //print resulting DPDA 00099 //******************************* 00100 std::cout << "***************** RESULT *****************" << std::endl; 00101 rPd.Write(); 00102 00103 //******************************* 00104 //print words that are possible in the closed loop 00105 //******************************* 00106 LangK test(rPd); 00107 test.FindLangK(50); 00108 test.PrintWords(); 00109 00110 return 0; 00111 } 00112 libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen |