pd_counterexample_griffin.cpp

Go to the documentation of this file.
00001 /** @file pd_counterexample_griffin.cpp  
00002 
00003 Synthesizes the minimal restrictive supervisor for a combination of plant and specification presented in the appendix of the technical report by Schneider and Schmuck (referenced at the webpage of this plugin). This is a counterexample to the results by Griffin (2008) as his algorithm returns a real subset of the supremal controllable sublanguage. Using our tool (i.e. this tutorial), the correct supervisor is synthesized.
00004 
00005 To run the tutorial and both save the output to a file and display it in the terminal, use 
00006 "./pd_counterexample_griffin ls -l 2>&1 | tee pd_counterexample_griffin.txt" 
00007 
00008 @ingroup Tutorials 
00009 
00010 @include pd_counterexample_griffin.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 specification, a pushdown generator
00030   //************************************************
00031   PushdownGenerator g;
00032    
00033   //insert states
00034   g.InsState("q0");
00035   g.InsState("q1");
00036   g.InsState("q2");
00037 
00038   //insert stack symbols
00039   Idx lambda = g.InsStackSymbol(FAUDES_PD_LAMBDA); //always use FAUDES_PD_LAMBDA for lambda!
00040   Idx dot = g.InsStackSymbol("dot");
00041   Idx square = g.SetStackBottom("square");
00042   
00043   //insert events
00044   g.InsControllableEvent("a");
00045   g.InsControllableEvent("b");
00046   g.InsUncontrollableEvent("u");
00047   //g.InsUncontrollableEvent(FAUDES_PD_LAMBDA); //here, we do not have lambda-transitions
00048   
00049   //build stack symbol vectors to be inserted as pop and push attributes of transitions
00050   std::vector<Idx> vLambda; //vLambda is the abbreviation for the empty string
00051   vLambda.push_back(lambda);
00052 
00053   std::vector<Idx> vSquare; //vSquare is the abbreviation for the string "Box" 
00054   vSquare.push_back(square);
00055 
00056   std::vector<Idx> vDot; //vDot is the abbreviation for the string "Dot" 
00057   vDot.push_back(dot);
00058 
00059   std::vector<Idx> vDotSquare;  // vDotSquare is the abbreviation for the string "Dot Box" 
00060   vDotSquare.push_back(dot);    // here the dot is pushed AFTER (popped BEFORE) the Box
00061   vDotSquare.push_back(square); 
00062 
00063   std::vector<Idx> vDotDot; // vDotDot is the abbreviation for the string "Dot Dot"
00064   vDotDot.push_back(dot);  // here two dots are pushed (popped)
00065   vDotDot.push_back(dot);
00066   
00067   //insert transitions
00068   g.SetTransition("q0", "a", "q0",vSquare,vDotSquare);
00069   g.SetTransition("q0", "a", "q0",vDot,vDotDot);
00070   g.SetTransition("q0", "b", "q1",vDot,vLambda);
00071   g.SetTransition("q1", "u", "q2",vDot,vDot);
00072   
00073   //set state attributes
00074   g.SetInitState("q0"); // one initial state
00075   g.SetMarkedState("q0");//here all states are marked, as required by the algorithm of Griffin (2008)
00076   g.SetMarkedState("q1");
00077   g.SetMarkedState("q2");
00078   
00079   //*******************************
00080   //create the plant, a DFA
00081   //*******************************
00082   System s;
00083   
00084   s.InsState("p0");
00085   s.InsState("p1");
00086   s.InsState("p2");
00087   
00088   s.InsControllableEvent("a");
00089   s.InsControllableEvent("b");
00090   s.InsUncontrollableEvent("u");
00091   
00092   s.SetTransition("p0", "a", "p0");
00093   s.SetTransition("p0", "b", "p1");
00094   s.SetTransition("p1", "u", "p2");
00095   
00096   s.SetInitState("p0"); // one initial state
00097   s.SetMarkedState("p0");//here all states are marked, as required by the algorithm of Griffin (2008)
00098   s.SetMarkedState("p1");
00099   s.SetMarkedState("p2");
00100 
00101   //*******************************
00102   //print plant and specification
00103   //*******************************
00104   g.Write();
00105   s.Write();
00106   
00107   //*******************************
00108   //call synthesis algorithm
00109   //*******************************
00110   PushdownGenerator rPd;
00111   PushdownConstructController(g,s,rPd);
00112   
00113   //*******************************
00114   //print result
00115   //*******************************
00116   std::cout << "***************** RESULT *****************" << std::endl;
00117   rPd.Write();
00118 
00119   //*******************************
00120   //print words that are possible in the closed loop 
00121   //*******************************
00122   LangK test(rPd);
00123   test.FindLangK(50); //at most 50 are checked when generating words in the language
00124   test.PrintWords();
00125   
00126   return 0;
00127 }
00128 

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