op_ex_synthesis.cppGo to the documentation of this file.00001 /** @file op_ex_synthesis.cpp 00002 00003 Tutorial, synthesis of natural projections with certain properties. 00004 00005 Thie tutorial describes the computation of a natural projection that is 00006 - an Lm-observer 00007 - an Lm-observer and locally control consistent (LCC) 00008 - an Lm-observer and output control consistent (OCC) 00009 The resulting abstractions also illustrate that the respective conditions imply each other: 00010 Lm-observer and OCC => Lm-observer and LCC => Lm-observer 00011 00012 @ingroup Tutorials 00013 00014 @include op_ex_synthesis.cpp 00015 */ 00016 00017 #include <stdio.h> 00018 #include <iostream> 00019 #include <libfaudes.h> 00020 00021 00022 // make libFAUDES namespace available 00023 using namespace faudes; 00024 00025 int main(int argc, char* argv[]) { 00026 ///////////////////////////// 00027 //Synthesis of an Lm-observer 00028 ///////////////////////////// 00029 00030 // construct original Generator from file 00031 System genOrig = System("data/ex_synthesis/ex_natural_all.gen"); 00032 genOrig.GraphWrite("data/ex_synthesis/ex_natural_all.png"); 00033 // construct initial abstraction alphabet from file 00034 EventSet highAlph = EventSet("data/ex_synthesis/ex_natural_all.alph", "Alphabet"); 00035 // compute an abstraction that is an Lm-observer while keeping the events in the original abstraction alphabet 00036 EventSet newHighAlph; 00037 System genClosed(genOrig); 00038 Generator genDyn; 00039 // compute closed observer 00040 calcClosedObserver(genClosed,highAlph); 00041 System genClosedProj; 00042 aProject(genClosed,highAlph,genClosedProj); 00043 genClosedProj.Write("data/ex_synthesis/ex_natural_closed_proj.gen"); 00044 genClosedProj.GraphWrite("data/ex_synthesis/ex_natural_closed_proj.png"); 00045 // compute natural observer 00046 highAlph = EventSet("data/ex_synthesis/ex_natural_all.alph", "Alphabet"); 00047 calcNaturalObserver(genClosed,highAlph); 00048 highAlph.Write(); 00049 aProject(genClosed,highAlph,genClosedProj); 00050 genClosedProj.Write("data/ex_synthesis/ex_natural_obs_proj.gen"); 00051 genClosedProj.GraphWrite("data/ex_synthesis/ex_natural_obs_proj.png"); 00052 //genClosedProj.GraphWrite("data/ex_synthesis/ex_natural_obs_proj.svg"); 00053 00054 // MSA-observer 00055 highAlph = EventSet("data/ex_synthesis/ex_natural_all.alph", "Alphabet"); 00056 System genMSA(genOrig); 00057 Generator genDynMSA; 00058 // compute natural observer 00059 calcMSAObserver(genClosed,highAlph); 00060 highAlph.Write(); 00061 aProject(genClosed,highAlph,genClosedProj); 00062 genClosedProj.Write("data/ex_synthesis/ex_natural_msa_proj.gen"); 00063 genClosedProj.GraphWrite("data/ex_synthesis/ex_natural_msa_proj.png"); 00064 00065 // Natural observer with LCC 00066 highAlph = EventSet("data/ex_synthesis/ex_natural_all.alph", "Alphabet"); 00067 System genLCC(genOrig); 00068 Generator genDynLCC; 00069 EventSet controllableEvents; 00070 //controllableEvents.Insert("gamma"); 00071 controllableEvents.Insert("a"); 00072 controllableEvents.Insert("f"); 00073 controllableEvents.Insert("g"); 00074 controllableEvents.Insert("h"); 00075 // compute natural observer with lcc 00076 calcNaturalObserverLCC(genLCC,controllableEvents, highAlph); 00077 highAlph.Write(); 00078 aProject(genLCC,highAlph,genClosedProj); 00079 genClosedProj.Write("data/ex_synthesis/ex_natural_obslcc_proj.gen"); 00080 genClosedProj.GraphWrite("data/ex_synthesis/ex_natural_obslcc_proj.png"); 00081 00082 // MSA observer with LCC 00083 highAlph = EventSet("data/ex_synthesis/ex_natural_all.alph", "Alphabet"); 00084 genDynLCC.Clear(); 00085 // compute natural observer with lcc 00086 calcMSAObserverLCC(genLCC,controllableEvents, highAlph); 00087 highAlph.Write(); 00088 aProject(genLCC,highAlph,genClosedProj); 00089 genClosedProj.Write("data/ex_synthesis/ex_natural_msalcc_proj.gen"); 00090 genClosedProj.GraphWrite("data/ex_synthesis/ex_natural_msalcc_proj.png"); 00091 00092 00093 // ======================================================== 00094 // Observer comptations with event relabeling 00095 // ======================================================== 00096 genOrig = System("data/ex_synthesis/ex_relabel_all.gen"); 00097 genOrig.GraphWrite("data/ex_synthesis/ex_relabel_all.png"); 00098 System genObs(genOrig); 00099 std::map< Idx, std::set< Idx > > mapRelabeledEvents; 00100 highAlph = EventSet("data/ex_synthesis/ex_natural_all.alph", "Alphabet"); 00101 calcAbstAlphClosed(genObs, highAlph, newHighAlph, mapRelabeledEvents); 00102 // Write the resulting generator and the new high-level alphabet to a file 00103 genObs.Write("data/ex_synthesis/ex_relabel_closed_result.gen"); 00104 genObs.GraphWrite("data/ex_synthesis/ex_relabel_closed_result.png"); 00105 newHighAlph.Write("data/ex_synthesis/ex_relabel_closed_result.alph"); 00106 // evaluate the natural projection for the resulting generator and high-level alphabet 00107 System genHigh; 00108 aProject(genObs, newHighAlph, genHigh); 00109 // Write the high-level generator to a file 00110 genHigh.Write("data/ex_synthesis/ex_relabel_closed_high.gen"); 00111 genHigh.GraphWrite("data/ex_synthesis/ex_relabel_closed_high.png"); 00112 std::cout << "##########################################################################\n"; 00113 std::cout << "# Lm-observer computed; the result can be found in the folder./results/ex_synthesis\n"; 00114 std::cout << "##########################################################################\n"; 00115 00116 ////////////////////////////////////////////////////////////////////////////////// 00117 // Synthesis of a natural projection that fulfills local control consistency (LCC) 00118 ////////////////////////////////////////////////////////////////////////////////// 00119 00120 // read the oritinal generator and high-level alphabetd from file input 00121 genObs = genOrig; 00122 highAlph.Read("data/ex_synthesis/ex_natural_all.alph", "Alphabet"); 00123 // compute an abstraction that is an Lm-observer and LCC whilc keeping the events in the original abstraction alphabet 00124 newHighAlph.Clear(); 00125 mapRelabeledEvents.clear(); 00126 calcAbstAlphObs(genObs, highAlph, newHighAlph, mapRelabeledEvents); 00127 genObs.Write("data/ex_synthesis/ex_relabel_obs_result.gen"); 00128 genObs.GraphWrite("data/ex_synthesis/ex_relabel_obs_result.png"); 00129 newHighAlph.Write("data/ex_synthesis/ex_relabel_obs_result.alph"); 00130 // evaluate the natural projection for the resulting generator and high-level alphabet 00131 aProject(genObs, newHighAlph, genHigh); 00132 // Write the high-level generator to a file 00133 genHigh.Write("data/ex_synthesis/ex_relabel_obs_high.gen"); 00134 genHigh.GraphWrite("data/ex_synthesis/ex_relabel_obs_high.png"); 00135 std::cout << "################################################################################\n"; 00136 std::cout << "# Lm-observer computed; the result can be found in the folder./results/ex_synthesis\n"; 00137 std::cout << "################################################################################\n"; 00138 00139 ////////////////////////////////////////////////////////////////////////////////// 00140 // Synthesis of a natural projection that fulfills local control consistency (LCC) 00141 ////////////////////////////////////////////////////////////////////////////////// 00142 00143 // read the oritinal generator and high-level alphabetd from file input 00144 genObs = genOrig; 00145 highAlph.Read("data/ex_synthesis/ex_natural_all.alph", "Alphabet"); 00146 // compute an abstraction that is an Lm-observer and LCC whilc keeping the events in the original abstraction alphabet 00147 newHighAlph.Clear(); 00148 mapRelabeledEvents.clear(); 00149 calcAbstAlphMSA(genObs, highAlph, newHighAlph, mapRelabeledEvents); 00150 genObs.Write("data/ex_synthesis/ex_relabel_msa_result.gen"); 00151 genObs.GraphWrite("data/ex_synthesis/ex_relabel_msa_result.png"); 00152 newHighAlph.Write("data/ex_synthesis/ex_relabel_msa_result.alph"); 00153 // evaluate the natural projection for the resulting generator and high-level alphabet 00154 aProject(genObs, newHighAlph, genHigh); 00155 // Write the high-level generator to a file 00156 genHigh.Write("data/ex_synthesis/ex_relabel_msa_high.gen"); 00157 genHigh.GraphWrite("data/ex_synthesis/ex_relabel_msa_high.png"); 00158 std::cout << "################################################################################\n"; 00159 std::cout << "# MSA-observer omputed; the result can be found in the folder./results/ex_synthesis\n"; 00160 std::cout << "################################################################################\n"; 00161 00162 00163 ////////////////////////////////////////////////////////////////////////////////// 00164 // Synthesis of a natural projection that fulfills local control consistency (LCC) with relabeling 00165 ////////////////////////////////////////////////////////////////////////////////// 00166 00167 // read the oritinal generator and high-level alphabetd from file input 00168 genObs = genOrig; 00169 highAlph.Read("data/ex_synthesis/ex_natural_all.alph", "Alphabet"); 00170 // compute an abstraction that is an Lm-observer and LCC whilc keeping the events in the original abstraction alphabet 00171 newHighAlph.Clear(); 00172 mapRelabeledEvents.clear(); 00173 calcAbstAlphObsLCC(genObs, highAlph, newHighAlph, mapRelabeledEvents); 00174 genObs.Write("data/ex_synthesis/ex_relabel_obslcc_result.gen"); 00175 genObs.GraphWrite("data/ex_synthesis/ex_relabel_obslcc_result.png"); 00176 newHighAlph.Write("data/ex_synthesis/ex_relabel_obslcc_result.alph"); 00177 // evaluate the natural projection for the resulting generator and high-level alphabet 00178 aProject(genObs, newHighAlph, genHigh); 00179 // Write the high-level generator to a file 00180 genHigh.Write("data/ex_synthesis/ex_relabel_obslcc_high.gen"); 00181 genHigh.GraphWrite("data/ex_synthesis/ex_relabel_obslcc_high.png"); 00182 std::cout << "################################################################################\n"; 00183 std::cout << "# Lm-observer with LCC computed; the result can be found in the folder./results/ex_synthesis\n"; 00184 std::cout << "################################################################################\n"; 00185 00186 ////////////////////////////////////////////////////////////////////////////////// 00187 // Synthesis of a natural projection that fulfills local control consistency (LCC) 00188 ////////////////////////////////////////////////////////////////////////////////// 00189 00190 // read the oritinal generator and high-level alphabetd from file input 00191 genObs = genOrig; 00192 highAlph.Read("data/ex_synthesis/ex_natural_all.alph", "Alphabet"); 00193 // compute an abstraction that is an Lm-observer and LCC whilc keeping the events in the original abstraction alphabet 00194 newHighAlph.Clear(); 00195 mapRelabeledEvents.clear(); 00196 calcAbstAlphMSALCC(genObs, highAlph, newHighAlph, mapRelabeledEvents); 00197 genObs.Write("data/ex_synthesis/ex_relabel_msalcc_result.gen"); 00198 genObs.GraphWrite("data/ex_synthesis/ex_relabel_msalcc_result.png"); 00199 newHighAlph.Write("data/ex_synthesis/ex_relabel_msalcc_result.alph"); 00200 // evaluate the natural projection for the resulting generator and high-level alphabet 00201 aProject(genObs, newHighAlph, genHigh); 00202 // Write the high-level generator to a file 00203 genHigh.Write("data/ex_synthesis/ex_relabel_msalcc_high.gen"); 00204 genHigh.GraphWrite("data/ex_synthesis/ex_relabel_msalcc_high.png"); 00205 std::cout << "################################################################################\n"; 00206 std::cout << "# MSA-observer with LCC computed; the result can be found in the folder./results/ex_synthesis\n"; 00207 std::cout << "################################################################################\n"; 00208 00209 return 0; 00210 } libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen |