libFAUDES
Sections
Index
|
con_decomposability.cppGo to the documentation of this file.00001 /** @file con_decomposability.cpp Conditionaldecomposability */ 00002 00003 /* 00004 * Implementation of the Conditionally decomposable algorithm 00005 * 00006 * Copyright (C) 2011 Tomas Masopust 00007 * 00008 */ 00009 00010 00011 #include "con_decomposability.h" 00012 #include <vector> 00013 00014 namespace faudes { 00015 00016 bool IsConditionalDecomposable(const Generator& gen, const EventSetVector& rAlphabets, const EventSet& ek, Generator& proof) { 00017 FD_DF("Conditionaldecomposability checking..."); 00018 00019 // the generator must be deterministic 00020 if (gen.IsDeterministic() == false) { 00021 std::stringstream errstr; 00022 errstr << "Generator must be deterministic, but is nondeterministic"; 00023 throw Exception("ConditionalDecomposability", errstr.str(), 201); 00024 } 00025 00026 // at least two alphabets in the vector 00027 if (rAlphabets.Size() < 2) { 00028 std::stringstream errstr; 00029 errstr << "At least two alphabets must be included in the EventSetVector"; 00030 throw Exception("ConditionalDecomposability", errstr.str(), 201); 00031 } 00032 00033 Idx i; 00034 EventSetVector ee = rAlphabets; // Vector of input alphabets 00035 EventSet unionset; // contains union of Ei 00036 EventSet shared; // contains union of intersections 00037 00038 // Compute unionset 00039 for (i = 0; i < ee.Size(); i++) { 00040 SetUnion(unionset,ee.At(i),unionset); 00041 } 00042 00043 // Compute the set of shared events 00044 for (i = 1; i < ee.Size(); i++) { 00045 EventSet eHelpInt; 00046 SetIntersection(ee.At(i-1),ee.At(i),eHelpInt); 00047 SetUnion(shared,eHelpInt,shared); 00048 } 00049 00050 // Alphabet of the generator must be under union Ei 00051 bool ok = SetInclusion(gen.Alphabet(),unionset); 00052 if (ok == false) { 00053 std::stringstream errstr; 00054 errstr << "Generator alphabet is not included in union of the alphabets"; 00055 throw Exception("ConditionalDecomposability", errstr.str(), 100); 00056 } 00057 00058 // Alphabet of the generator must contain Ek 00059 ok = SetInclusion(ek,gen.Alphabet()); 00060 if (ok == false) { 00061 std::stringstream errstr; 00062 errstr << "Generator alphabet does not include the alphabet ek"; 00063 throw Exception("ConditionalDecomposability", errstr.str(), 100); 00064 } 00065 00066 // Ek must contain all shared events 00067 ok = SetInclusion(shared,ek); 00068 if (ok == false) { 00069 std::stringstream errstr; 00070 errstr << "Ek does not include all shared events"; 00071 throw Exception("ConditionalDecomposability", errstr.str(), 100); 00072 } 00073 00074 // Make copies of the generator 00075 GeneratorVector copies; 00076 EventSet unionsetNew = unionset; // unionset with new events 00077 EventSet::Iterator eit; 00078 00079 for (i = 0; i < ee.Size(); i++) { 00080 EventSet uEiEk; 00081 SetUnion(ee.At(i),ek,uEiEk); 00082 EventSet EiEkdifUnionset; 00083 SetDifference(unionset,uEiEk,EiEkdifUnionset); 00084 Generator copy = gen; 00085 for (eit = EiEkdifUnionset.Begin(); eit != EiEkdifUnionset.End(); ++eit) { 00086 copy.EventRename(*eit,copy.UniqueEventName("")); 00087 } 00088 copies.Append(copy); 00089 SetUnion(unionsetNew,copy.Alphabet(),unionsetNew); 00090 } 00091 00092 // Compute tilde G 00093 Generator tildeG = copies.At(0); 00094 for (i = 1; i < copies.Size(); i++) { 00095 Parallel(tildeG,copies.At(i),tildeG); 00096 } 00097 00098 // Compute Inverse image of G 00099 Generator invGen; 00100 aInvProject(gen,unionsetNew,invGen); 00101 Trim(tildeG); 00102 Trim(invGen); 00103 if (LanguageInclusion(tildeG,invGen)) { 00104 Generator p; 00105 proof = p; // the proof language is empty 00106 return true; 00107 } 00108 00109 // Save proof automaton showing that it is not CD 00110 LanguageComplement(invGen); 00111 Generator proofGen; 00112 LanguageIntersection(invGen,tildeG,proofGen); 00113 Trim(proofGen); 00114 //StateMin(proofGen,proofGen); 00115 proofGen.ClearStateNames(); 00116 proof = proofGen; 00117 00118 return false; 00119 } 00120 00121 00122 } // name space 00123 00124 00125 |
libFAUDES 2.20s --- 2011.10.12 --- c++ source docu by doxygen