syn_supcmpl.cpp
Go to the documentation of this file.
1/** @file syn_supcmpl.cpp Supremal complete sublanguage for infinite time behaviours */
2
3/* FAU Discrete Event Systems Library (libfaudes)
4
5 Copyright (C) 2010, 2025 Thomas Moor
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
20
21
22//#define FAUDES_DEBUG_FUNCTION
23
24#include "syn_supcmpl.h"
25#include "syn_supcon.h"
26#include "syn_supnorm.h"
27#include "syn_functions.h"
28
29#include "omg_include.h"
30
31namespace faudes {
32
33
34
35/*
36***************************************************************************************
37***************************************************************************************
38 Implementation SupConCmplClosed
39***************************************************************************************
40***************************************************************************************
41*/
42
43
44// supcon complete
46 const Generator& rPlantGen,
47 const EventSet& rCAlph,
48 const Generator& rSpecGen,
49 Generator& rResGen)
50{
51 FD_DF("SupConCmplClosed(" << rPlantGen.Name() << "," << rSpecGen.Name()<< ")");
52
53 // exceptions on invalid parameters, same as std synthesis
54 ControlProblemConsistencyCheck(rPlantGen,rCAlph,rSpecGen);
55
56 // prepare result
57 Generator* pResGen = &rResGen;
58 if(&rResGen== &rPlantGen || &rResGen== &rSpecGen) {
59 pResGen= rResGen.New();
60 }
61 pResGen->Clear();
62 pResGen->Name("SupConCmplClosed("+rPlantGen.Name()+", "+rSpecGen.Name()+")");
63 pResGen->InjectAlphabet(rPlantGen.Alphabet());
64
65 //check for trivial result
66 if(rSpecGen.InitStatesEmpty()){
67 FD_DF("SupConCmplClosed: empty language specification - empty result.");
68 }
69
70
71 // have a reverse composition map
72 std::map< std::pair<Idx,Idx>, Idx> revmap;
73
74 // parallel composition (result is reachable)
75 SupConProduct(rPlantGen, rCAlph, rSpecGen, revmap, *pResGen);
76
77 // make resulting generator complete and controllabel
78 while(true) {
79 Idx state_num = pResGen->Size();
80 if(pResGen->InitStates().Empty()) break;
81 pResGen->Complete();
82 if(pResGen->InitStates().Empty()) break;
83 SupConClosedUnchecked(rPlantGen, rCAlph, *pResGen);
84 if(pResGen->Size() == state_num) break;
85 }
86
87 // convenience state names
88 if(rPlantGen.StateNamesEnabled() && rSpecGen.StateNamesEnabled() && rResGen.StateNamesEnabled())
89 SetComposedStateNames(rPlantGen, rSpecGen, revmap, *pResGen);
90 else
91 pResGen->StateNamesEnabled(false);
92
93 // copy result
94 if(pResGen != &rResGen) {
95 pResGen->Move(rResGen);
96 delete pResGen;
97 }
98
99}
100
101
102// user wrapper
104 const System& rPlantGen,
105 const Generator& rSpecGen,
106 Generator& rResGen)
107{
108
109 // execute
110 SupConCmplClosed(rPlantGen, rPlantGen.ControllableEvents(),rSpecGen,rResGen);
111
112 // copy all attributes of input alphabet
113 rResGen.EventAttributes(rPlantGen.Alphabet());
114
115}
116
117
118
119
120/*
121***************************************************************************************
122***************************************************************************************
123 Implementation SupConCmpl
124***************************************************************************************
125***************************************************************************************
126*/
127
128
129// supcon complete
131 const Generator& rPlantGen,
132 const EventSet& rCAlph,
133 const Generator& rSpecGen,
134 Generator& rResGen)
135{
136 FD_DF("SupConCmpl(" << rPlantGen.Name() << "," << rSpecGen.Name()<< ")");
137
138 // exceptions on invalid parameters, same as std synthesis
139 ControlProblemConsistencyCheck(rPlantGen,rCAlph,rSpecGen);
140
141 // prepare result
142 Generator* pResGen = &rResGen;
143 if(&rResGen== &rPlantGen || &rResGen== &rSpecGen) {
144 pResGen= rResGen.New();
145 }
146 pResGen->Clear();
147 pResGen->Name("SupConCmpl("+rPlantGen.Name()+", "+rSpecGen.Name()+")");
148 pResGen->InjectAlphabet(rPlantGen.Alphabet());
149
150 //check for trivial result
151 if(rSpecGen.InitStatesEmpty()){
152 FD_DF("SupConCmpl: empty language specification - empty result.");
153 }
154
155
156 // have a reverse composition map
157 std::map< std::pair<Idx,Idx>, Idx> revmap;
158
159 // parallel composition (result is reachable)
160 SupConProduct(rPlantGen, rCAlph, rSpecGen, revmap, *pResGen);
161
162 // make resulting generator complete and controllabel and coaccessible
163 while(true) {
164 Idx state_num = pResGen->Size();
165 if(pResGen->InitStates().Empty()) break;
166 pResGen->Coaccessible();
167 if(pResGen->InitStates().Empty()) break;
168 pResGen->Complete();
169 if(pResGen->InitStates().Empty()) break;
170 SupConClosedUnchecked(rPlantGen, rCAlph, *pResGen);
171 if(pResGen->Size() == state_num) break;
172 }
173
174 // convenience state names
175 if(rPlantGen.StateNamesEnabled() && rSpecGen.StateNamesEnabled() && rResGen.StateNamesEnabled())
176 SetComposedStateNames(rPlantGen, rSpecGen, revmap, *pResGen);
177 else
178 pResGen->StateNamesEnabled(false);
179
180 // copy result
181 if(pResGen != &rResGen) {
182 pResGen->Move(rResGen);
183 delete pResGen;
184 }
185
186}
187
188
189// user wrapper
191 const System& rPlantGen,
192 const Generator& rSpecGen,
193 Generator& rResGen)
194{
195
196 // execute
197 SupConCmpl(rPlantGen, rPlantGen.ControllableEvents(),rSpecGen,rResGen);
198
199 // copy all attributes of input alphabet
200 rResGen.EventAttributes(rPlantGen.Alphabet());
201
202}
203
204
205
206/*
207***************************************************************************************
208***************************************************************************************
209 Implementation SupConNormCmpl
210***************************************************************************************
211***************************************************************************************
212*/
213
214
215// SupConNormCmpl(rL,rCAlph,rOAlph,rK,rResult)
217 const Generator& rL,
218 const EventSet& rCAlph,
219 const EventSet& rOAlph,
220 const Generator& rK,
221 Generator& rResult)
222{
223 FD_DF("SupConNormCmpl(" << rL.Name() << "," << rK.Name() << ")");
224 // initialize: K0
225 Generator K0;
226 K0.StateNamesEnabled(false);
227 Product(rL,rK,K0);
228 K0.Coaccessible();
229 // initialize: closure(rL)
230 Generator L=rL;
231 L.StateNamesEnabled(false);
232 L.Trim();
233 MarkAllStates(L);
234 // loop
235 Generator Ki=K0;
236 Ki.StateNamesEnabled(false);
237 while(1) {
238 FD_DF("SupConNormCmpl(" << rL.Name() << "," << rK.Name() << "): #" << Ki.Size() << " m#" << Ki.MarkedStatesSize());
239 // keep copy of recent
240 rResult=Ki;
241 // cheep closure (for coreachable generator)
242 Ki.InjectMarkedStates(Ki.States());
243 // synthesise closed
244 SupConNormClosed(L,rCAlph,rOAlph,Ki,Ki);
245 Complete(Ki);
246 // restrict
247 Product(K0,Ki,Ki);
248 Ki.Coaccessible();
249 // test (sequence is decreasing anyway)
250 if(LanguageInclusion(rResult,Ki)) break;
251 }
252 FD_DF("SupConNormCmpl(" << rL.Name() << "," << rK.Name() << "): done");
253}
254
255
256/** rti wrapper */
258 const System& rPlantGen,
259 const Generator& rSpecGen,
260 Generator& rResGen)
261{
262 FD_DF("SupConNormCmpl(" << rPlantGen.Name() << "," << rSpecGen.Name() << "): rti wrapper");
263 // prepare result
264 Generator* pResGen = &rResGen;
265 if(&rResGen== &rPlantGen || &rResGen== &rSpecGen) {
266 pResGen= rResGen.New();
267 }
268 // execute
269 SupConNormCmpl(rPlantGen,rPlantGen.ControllableEvents(),rPlantGen.ObservableEvents(),rSpecGen,*pResGen);
270 // copy all attributes of input alphabet
271 pResGen->EventAttributes(rPlantGen.Alphabet());
272 // copy result
273 if(pResGen != &rResGen) {
274 pResGen->Move(rResGen);
275 delete pResGen;
276 }
277}
278
279
280
281
282} // name space
#define FD_DF(message)
const std::string & Name(void) const
const TaEventSet< EventAttr > & Alphabet(void) const
EventSet ControllableEvents(void) const
EventSet ObservableEvents(void) const
const EventSet & Alphabet(void) const
virtual void Move(vGenerator &rGen)
bool InitStatesEmpty(void) const
const StateSet & InitStates(void) const
virtual vGenerator * New(void) const
void InjectMarkedStates(const StateSet &rNewMarkedStates)
Idx MarkedStatesSize(void) const
virtual void EventAttributes(const EventSet &rEventSet)
bool StateNamesEnabled(void) const
Idx Size(void) const
virtual void Clear(void)
const StateSet & States(void) const
void InjectAlphabet(const EventSet &rNewalphabet)
bool Empty(void) const
void Complete(vGenerator &rGen)
bool LanguageInclusion(const Generator &rGen1, const Generator &rGen2)
void Product(const Generator &rGen1, const Generator &rGen2, Generator &rResGen)
void MarkAllStates(vGenerator &rGen)
void SupConNormClosed(const Generator &rL, const EventSet &rCAlph, const EventSet &rOAlph, const Generator &rK, Generator &rResult)
void SupConNormCmpl(const Generator &rL, const EventSet &rCAlph, const EventSet &rOAlph, const Generator &rK, Generator &rResult)
void SupConCmplClosed(const Generator &rPlantGen, const EventSet &rCAlph, const Generator &rSpecGen, Generator &rResGen)
void SupConCmpl(const Generator &rPlantGen, const EventSet &rCAlph, const Generator &rSpecGen, Generator &rResGen)
uint32_t Idx
void SetComposedStateNames(const Generator &rGen1, const Generator &rGen2, const std::map< std::pair< Idx, Idx >, Idx > &rCompositionMap, Generator &rGen12)
void ControlProblemConsistencyCheck(const GeneratorVector &rPlantGenVec, const EventSet &rConAlph, const GeneratorVector &rSpecGenVec)
void SupConClosedUnchecked(const Generator &rPlantGen, const EventSet &rCAlph, Generator &rSupCandGen)
void SupConProduct(const Generator &rPlantGen, const EventSet &rCAlph, const Generator &rSpecGen, std::map< std::pair< Idx, Idx >, Idx > &rCompositionMap, Generator &rResGen)

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