pd_tutorial.cpp

Go to the documentation of this file.
00001 /** @file pd_tutorial.cpp  
00002 
00003 Tutorial, pushdown plugin.
00004 @ingroup Tutorials 
00005 
00006 @include pd_tutorial.cpp
00007 
00008 */
00009 
00010 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes)
00011 
00012    Copyright (C) 2013  Stefan Jacobi, Sven Schneider, Anne-Kathrin Hess
00013 
00014 */
00015 
00016 #include "libfaudes.h"
00017 #include "pd_include.h"
00018 
00019 // make the faudes namespace available to our program
00020 using namespace faudes;
00021 
00022 int main(){
00023   
00024   //*******************************
00025   //create the specification, a pushdown generator
00026   //*******************************
00027   PushdownGenerator g;
00028    
00029   //insert states
00030   g.InsState("s1");
00031   g.InsState("s2");
00032   g.InsState("s3");
00033 
00034   //insert stack symbols
00035   Idx lambda = g.InsStackSymbol(FAUDES_PD_LAMBDA); //always use FAUDES_PD_LAMBDA for empty stack symbol!
00036   Idx dot = g.InsStackSymbol("dot");
00037   Idx square = g.SetStackBottom("square");
00038   
00039   //insert events
00040   g.InsControllableEvent("a");
00041   g.InsEvent("b");
00042   g.InsUncontrollableEvent(FAUDES_PD_LAMBDA); //always use FAUDES_PD_LAMBDA for empty event!
00043   
00044   //build stack symbol vectors to be inserted as pop and push attributes of transitions
00045   std::vector<Idx> vLambda;
00046   vLambda.push_back(lambda);
00047   std::vector<Idx> vSquare;
00048   vSquare.push_back(square);
00049   std::vector<Idx> vDot;
00050   vDot.push_back(dot);
00051   std::vector<Idx> vDotSquare;
00052   vDotSquare.push_back(dot);
00053   vDotSquare.push_back(square);
00054   
00055   //insert transitions
00056   g.SetTransition("s1", "a", "s2",vSquare,vDotSquare);
00057   g.SetTransition("s2", "b", "s3",vDot,vDot);
00058   
00059   //set state attributes
00060   g.SetInitState("s1");
00061   g.SetMarkedState("s1");
00062   g.SetMarkedState("s2");
00063   g.SetMarkedState("s3");
00064   
00065   //*******************************
00066   //create the plant, a DFA
00067   //*******************************
00068   System s;
00069   
00070   s.InsState("s1");
00071   s.InsState("s2");
00072   s.InsState("s3");
00073   
00074   s.InsControllableEvent("a");         
00075   s.InsEvent("b");
00076   
00077   s.SetTransition("s1", "a", "s1");
00078   s.SetTransition("s1", "a", "s2");
00079   s.SetTransition("s2", "b", "s3");
00080   
00081   s.SetInitState("s1");              
00082   s.SetMarkedState("s3");
00083 
00084   //*******************************
00085   //print plant and specification
00086   //*******************************
00087   g.Write();
00088   s.Write();
00089   
00090   //*******************************
00091   //call synthesis algorithm
00092   //*******************************
00093   PushdownGenerator rPd;
00094   PushdownConstructController(g,s,rPd);
00095   
00096   //*******************************
00097   //print result
00098   //*******************************
00099   std::cout << "***************** RESULT *****************" << std::endl;
00100   rPd.Write();
00101 
00102   //*******************************
00103   //print words that are possible in the closed loop (only "ab" expected)
00104   //*******************************
00105   LangK test(rPd);
00106   test.FindLangK(50);
00107   test.PrintWords();
00108   
00109   return 0;
00110 }
00111 

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen