pev_abstraction.h
Go to the documentation of this file.
1/** @file pev_abstraction.h Conflict preserving abstractions */
2
3
4/* FAU Discrete Event Systems Library (libfaudes)
5
6 Copyright (C) 2023 Yiheng Tang
7 Copyright (C) 2025 Thomas Moor
8 Exclusive copyright is granted to Klaus Schmidt
9
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
14
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef PEV_ABSTRACTION_H
25#define PEV_ABSTRACTION_H
26
27#define PCOMPVER_VERB2(msg) \
28 { if(faudes::ConsoleOut::G()->Verb() >=2 ) { \
29 std::ostringstream cfl_line; cfl_line << msg << std::endl; faudes::ConsoleOut::G()->Write(cfl_line.str(),0,0,0);} }
30#define PCOMPVER_VERB1(msg) \
31 { if(faudes::ConsoleOut::G()->Verb() >=1 ) { \
32 std::ostringstream cfl_line; cfl_line << msg << std::endl; faudes::ConsoleOut::G()->Write(cfl_line.str(),0,0,0);} }
33#define PCOMPVER_VERB0(msg) \
34 { if(faudes::ConsoleOut::G()->Verb() >=0 ) { \
35 std::ostringstream cfl_line; cfl_line << msg << std::endl; faudes::ConsoleOut::G()->Write(cfl_line.str(),0,0,0);} }
36
37#include "pev_pgenerator.h"
38
39namespace faudes {
40
41// manually install omega events
42void AppendOmega(Generator& rGen);
43
44/**
45 * Shape generator by removing transitions that are preempted by higher priority altyernatives.
46 *
47 * @param rGen generator to shape
48 * @param rPrios event priorities
49 *
50 * @ingroup PrioritiesPlugin
51 */
52FAUDES_API void ShapePriorities(vGenerator& rGen, const EventPriorities& rPrios);
53
54/**
55 * Shape generator by removing transitions that are preempted by higher priority altyernatives.
56 *
57 * @param rPGen generator to shape incl. event priorities
58 *
59 * @ingroup PrioritiesPlugin
60 */
62
63/**
64 * Shape generator by removing transitions that are preempted by higher priority alternatives.
65 *
66 * @param rPGen generator to shape incl. event priorities
67 * @param rUpsilon only consider events in Upsilon for shaping
68 *
69 * @ingroup PrioritiesPlugin
70 */
71FAUDES_API void ShapeUpsilon(pGenerator& rPGen, const EventSet& rUpsilon);
72
73
74/**
75 * Shape generator by removing preempted transitions
76 *
77 * @param rGen generator to shape
78 * @param rPrevs set of preempting events
79 *
80 * @ingroup PrioritiesPlugin
81 */
82FAUDES_API void ShapePreemption(Generator& rGen, const EventSet& rPrevs);
83
84
85
86/**
87 * Nonconflicting Test
88 *
89 * Given a family of generators and global event priorities, decide whether or not the
90 * synchronous composition is non-conflicting under event priorisation. This functions
91 * implements a compositional approach to avoid an explicit representation of the composed
92 * overall system.
93 *
94 * @param rGvec generators to consider
95 * @param rPrevs global event priosities
96 * @return true for nonconflicting
97 *
98 * @ingroup PrioritiesPlugin
99 */
101 const GeneratorVector& rGvec,
102 const EventPriorities& rPrios);
103
104
105/**
106 * Nonconflicting Test
107 *
108 * Given a family of generators and global event priorities, decide whether or not the
109 * synchronous composition is non-conflicting under event priorisation. This function
110 * is a variant of faudes::IsPNonblocking that addresses a generalised concept of fairness.
111 *
112 * @param rPGvec generators to consider
113 * @param rPrios global event priosities
114 * @return true for nonconflicting
115 *
116 * @ingroup PrioritiesPlugin
117 */
119 const FairGeneratorVector& rFGvec,
120 const EventPriorities& rPrios);
121
122
123
124
125class CompVerify;
126
128public:
129 Candidate(void){}
130 Candidate(Generator& goi);
131 Candidate(Generator& goi, ProductCompositionMap map,std::pair<Candidate*, Candidate*> pair);
132 virtual ~Candidate();
136 std::map<Idx,Idx> MergeMap(){return mMergeMap;}
137 std::set<Idx> FindConcreteStates(Idx abstract);
138 bool IsInMergedClass(Idx concrete,Idx abstract);
140 std::pair<Candidate*,Candidate*> DecomposedPair(){return mDecomposedPair;}
142 void SetSilentevs(EventSet silentevs) {mSilentevs.Clear(); mSilentevs.InsertSet(silentevs);}
144 Idx Tau(){return mtau;}
145 void SetTau(Idx tau){mtau = tau;}
146
147
148 /*! re-imp conflict-eq abstraction below */
149 virtual void HidePrivateEvs(EventSet& silent); // derived class has variance
150
152 Generator& rGen,
153 TransSetX2EvX1& rRevTrans,
154 const std::list< StateSet >& rClasses,
155 const EventSet& silent);
156
157 void ExtendedTransRel(
158 const Generator& rGen,
159 const EventSet& rSilentAlphabet,
160 TransSet& rXTrans);
161
162 void IncomingTransSet(
163 const Generator& rGen,
164 const EventSet& silent,
165 const Idx& state,
166 std::set<std::pair<Idx, Idx>>& result);
167
168 void ActiveNonTauEvs(const Generator& rGen,
169 const EventSet& silent,
170 const Idx& state,
171 EventSet &result);
172
174 Generator& g,
175 const EventSet& silent);
176
178 Generator& g,
179 const EventSet& silent);
180
181
183 Generator& g,
184 const EventSet& silent);
185
186
188 Generator& g,
189 const EventSet& silent);
190
192 Generator& g,
193 const EventSet& silent);
194
195 virtual void MergeSilentLoops(
196 Generator& g,
197 const EventSet& silent);
198
200
202 Generator& g,
203 const EventSet& silent);
204
206
207 void BlockingEvent(
208 Generator& g,
209 const EventSet& silent);
210
212 Generator& g,
213 const EventSet& silent);
214
216 Generator& g,
217 const EventSet& silent);
218
219 virtual void ConflictEquivalentAbstraction(EventSet &silent);
220
221protected:
222 void DoAssign(Candidate cand);
223 Generator mGenRaw; // input generator, not abstracted yet
224 Generator mGenHidden; // generator after hiding private evs
225 Generator mGenMerged; // generator after state merging abstraction
226 std::map<Idx,Idx> mMergeMap; // map of states between mGenMerged and mGenRaw
227 EventSet mSilentevs; // original silent events before hiding.
228
230 // the composition map from the last iteration.
231 // Empty when not composed in the last iteration
232 // the compmap matches mGenRaw to some candidate pair
233 // in the latest iteration
235 std::pair<Candidate*, Candidate*> mDecomposedPair;
236};
237
238class PCandidate : public Candidate{
239public:
240 PCandidate (void){}
241 PCandidate (Generator &goi, EventSet pevs) : Candidate(goi), mPevs(pevs){}
242 PCandidate(Generator& goi, ProductCompositionMap map,std::pair<Candidate*, Candidate*> pair, EventSet pevs)
243 : Candidate(goi, map, pair), mPevs(pevs){}
245 EventSet Pevs() {return mPevs;}
246 void SetPSilentevs(EventSet psilentevs) {mPSilentevs.Clear(); mPSilentevs.InsertSet(psilentevs);}
247
248 Idx Ptau(){return mPtau;}
249 void SetPtau(Idx ptau){mPtau = ptau;}
250
251 /*!
252 * \brief HidePrivateEvs
253 * replace all private events
254 *
255 * \param silent
256 * private events which can be hidden
257 */
258 virtual void HidePrivateEvs(EventSet &silent);
259
261 Generator& g,
262 const EventSet& silent);
263
265 Generator& g,
266 const EventSet& silent,
267 const bool& flag);
268
269 virtual void MergeSilentLoops(
270 Generator &g,
271 const EventSet &silent);
272
273
274 virtual void ConflictEquivalentAbstraction(EventSet &silent);
275
276private:
277 void DoAssign(PCandidate cand);
280
282
283};
284
285
287public:
291 SynchCandidates(GeneratorVector& gvoi, const EventSet& pevs);
292 virtual ~SynchCandidates();
293 typedef std::list<Candidate*>::iterator Iterator;
294
297 void Insert(Candidate* cand) {mCandidates.push_back(cand);}
298 Idx Size(){return mCandidates.size();}
299
300protected:
301 void DoAssign(SynchCandidates synchcands);
302 std::list<Candidate*> mCandidates;
303};
304
305
306
307} // namespace faudes
308#endif // PEV_ABSTRACTION_H
#define FAUDES_API
void OnlySilentIncoming(Generator &g, const EventSet &silent)
void BlockingSilentEvent(Generator &g, const EventSet &silent)
void IncomingTransSet(const Generator &rGen, const EventSet &silent, const Idx &state, std::set< std::pair< Idx, Idx > > &result)
ProductCompositionMap ComposeMap()
virtual void HidePrivateEvs(EventSet &silent)
std::map< Idx, Idx > MergeMap()
void RemoveTauSelfloops(Generator &g, const EventSet &silent)
void SetTau(Idx tau)
void RemoveNonCoaccessibleOut(Generator &g)
void ActiveNonTauEvs(const Generator &rGen, const EventSet &silent, const Idx &state, EventSet &result)
void SetSilentevs(EventSet silentevs)
std::pair< Candidate *, Candidate * > DecomposedPair()
std::map< Idx, Idx > mMergeMap
void ActiveEventsANDEnabledContinuationRule(Generator &g, const EventSet &silent)
void MergeEquivalenceClasses(Generator &rGen, TransSetX2EvX1 &rRevTrans, const std::list< StateSet > &rClasses, const EventSet &silent)
std::pair< Candidate *, Candidate * > mDecomposedPair
virtual void MergeSilentLoops(Generator &g, const EventSet &silent)
void OnlySilentOutgoing(Generator &g, const EventSet &silent)
ProductCompositionMap mComposeMap
void DoAssign(Candidate cand)
virtual void ConflictEquivalentAbstraction(EventSet &silent)
bool IsInMergedClass(Idx concrete, Idx abstract)
void BlockingEvent(Generator &g, const EventSet &silent)
void WeakObservationEquivalentQuotient(Generator &g, const EventSet &silent)
std::set< Idx > FindConcreteStates(Idx abstract)
void ReverseObservationEquivalentQuotient(Generator &g, const EventSet &silent)
void ObservationEquivalentQuotient(Generator &g, const EventSet &silent)
void ExtendedTransRel(const Generator &rGen, const EventSet &rSilentAlphabet, TransSet &rXTrans)
void MergeNonCoaccessible(Generator &g)
virtual void InsertSet(const NameSet &rOtherSet)
virtual void HidePrivateEvs(EventSet &silent)
HidePrivateEvs replace all private events.
void SetPSilentevs(EventSet psilentevs)
void DoAssign(PCandidate cand)
void SetPtau(Idx ptau)
virtual void MergeSilentLoops(Generator &g, const EventSet &silent)
virtual void ConflictEquivalentAbstraction(EventSet &silent)
PCandidate(Generator &goi, EventSet pevs)
void ObservationEquivalenceQuotient_NonPreemptive(Generator &g, const EventSet &silent)
void ObservationEquivalenceQuotient_Preemptive(Generator &g, const EventSet &silent, const bool &flag)
PCandidate(Generator &goi, ProductCompositionMap map, std::pair< Candidate *, Candidate * > pair, EventSet pevs)
void Insert(Candidate *cand)
std::list< Candidate * >::iterator Iterator
std::list< Candidate * > mCandidates
void DoAssign(SynchCandidates synchcands)
virtual void Clear(void)
NameSet EventSet
vGenerator Generator
TBaseVector< FairGenerator > FairGeneratorVector
TBaseVector< Generator > GeneratorVector
void ShapePriorities(vGenerator &rGen, const EventPriorities &rPrios)
bool IsPFNonblocking(const FairGeneratorVector &rPGvec, const EventPriorities &rPrios)
void ShapePreemption(Generator &rGen, const EventSet &pevs)
bool IsPNonblocking(const GeneratorVector &rGvec, const EventPriorities &rPrios)
TpEventSet< AttributePriority > EventPriorities
uint32_t Idx
void ShapeUpsilon(vGenerator &rGen, const EventPriorities &rPrios, const EventSet &rUpsilon)
TpGenerator< AttributePGenGl, AttributeVoid, AttributePriority, AttributeVoid > pGenerator
void AppendOmega(Generator &rGen)

libFAUDES 2.33k --- 2025.09.16 --- c++ api documentaion by doxygen