syn_supcon.h
Go to the documentation of this file.
1/** @file syn_supcon.h Supremal controllable sublanguage */
2
3/* FAU Discrete Event Systems Library (libfaudes)
4
5 Copyright (C) 2006 Bernd Opitz
6 Copyright (C) 2007 Thomas Moor
7 Exclusive copyright is granted to Klaus Schmidt
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23
24#ifndef FAUDES_SUPCON_H
25#define FAUDES_SUPCON_H
26
27#include "corefaudes.h"
28#include <stack>
29
30namespace faudes {
31
32
33
34/**
35 * Test controllability
36 *
37 * Tests whether the candidate supervisor H is controllable w.r.t.
38 * the plant G. This implementation does not require the supervisor H to
39 * represent a sublanguage of the plant G.
40 *
41 * Parameter restrictions: both generators must be deterministic and
42 * share the same alphabet.
43 *
44 *
45 * @param rPlantGen
46 * Plant G
47 * @param rCAlph
48 * Controllable events
49 * @param rSupCandGen
50 * Supervisor candidate H
51 *
52 * @exception Exception
53 * - alphabets of generators don't match (id 100)
54 * - plant generator nondeterministic (id 201)
55 * - specification generator nondeterministic (id 203)
56 * - plant and Spec generator nondeterministic (id 204)
57 *
58 * @return
59 * true / false
60 *
61 * @ingroup SynthesisPlugIn
62 */
63extern FAUDES_API bool IsControllable(const Generator& rPlantGen, const EventSet& rCAlph, const Generator& rSupCandGen);
64
65
66/**
67 * Test controllability.
68 *
69 * Tests whether the candidate supervisor H is controllable w.r.t.
70 * the plant G. This implementation does not require the supervisor H to
71 * represent a sublanguage of the plant G.
72 *
73 *
74 * If the candidate fails to be controllable, this version will return a set of
75 * "critical" states of the candidate supervisor. These states are characterised by
76 * (a) being reachable in the parallel composition of plant and supervisor
77 * (b) disabeling an uncontrollable transition of the plant
78 * Note: this was reimplemented in libFAUDES 2.20b.
79 *
80 * Parameter restrictions: both generators must be deterministic and
81 * have the same alphabet.
82 *
83 * @param rPlantGen
84 * Plant G
85 * @param rCAlph
86 * Controllable events
87 * @param rSupCandGen
88 * Supervisor candicate H
89 * @param rCriticalStates
90 * Set of critical states
91 *
92 * @exception Exception
93 * - alphabets of generators don't match (id 200)
94 * - plant generator nondeterministic (id 201)
95 * - specification generator nondeterministic (id 203)
96 * - plant and Spec generator nondeterministic (id 204)
97 *
98 * @return
99 * true / false
100 *
101 * @ingroup SynthesisPlugIn
102 */
103extern FAUDES_API bool IsControllable(
104 const Generator& rPlantGen,
105 const EventSet& rCAlph,
106 const Generator& rSupCandGen,
107 StateSet& rCriticalStates);
108
109
110/**
111 * Test controllability.
112 *
113 * Tests whether the candidate supervisor h is controllable w.r.t.
114 * the plant g; this is a System wrapper for IsControllable
115 *
116 * @param rPlantGen
117 * Plant g generator
118 * @param rSupCandGen
119 * Supervisor candidate h generator
120 *
121 * @exception Exception
122 * Alphabets of generators don't match (id 500)
123 * Plant generator nondeterministic (id 501)
124 * Specification generator nondeterministic (id 503)
125 * Plant & Spec generator nondeterministic (id 504)
126 *
127 * @return
128 * true / false
129 *
130 * @ingroup SynthesisPlugIn
131 */
132extern FAUDES_API bool IsControllable(
133 const System& rPlantGen,
134 const Generator& rSupCandGen);
135
136
137/**
138 * Nonblocking Supremal Controllable Sublanguage
139 *
140 * Given a generator G (argument rPlantGen) and a specification language E (marked by argument rSpecGen),
141 * this procedures computes an automaton S such that
142 * Lm(S) is the supremal controllable sublanguage of Lm(G) ^ Lm(E) w.r.t. L(G).
143 * The result is given as a trim deterministic generator that
144 * may be used to supervise G in order to enforce E.
145 *
146 * See "C.G CASSANDRAS AND S. LAFORTUNE. Introduction to Discrete Event
147 * Systems. Kluwer, 1999." for base algorithm.
148 *
149 * Parameter restrictions: both generators must be deterministic and
150 * have the same alphabet.
151 *
152 *
153 * @param rPlantGen
154 * Plant G
155 * @param rCAlph
156 * Controllable events
157 * @param rSpecGen
158 * Specification Generator to mark E
159 * @param rResGen
160 * Reference to resulting Generator, the
161 * minimal restrictive nonblocking supervisor
162 *
163 * @exception Exception
164 * - alphabets of generators don't match (id 100)
165 * - plant nondeterministic (id 201)
166 * - spec nondeterministic (id 203)
167 * - plant and spec nondeterministic (id 204)
168 *
169 * @ingroup SynthesisPlugIn
170 *
171 */
172extern FAUDES_API void SupCon(
173 const Generator& rPlantGen,
174 const EventSet& rCAlph,
175 const Generator& rSpecGen,
176 Generator& rResGen);
177
178
179
180/**
181 * Nonblocking Supremal Controllable Sublanguage
182 *
183 * This is the RTI wrapper for
184 * SupCon(const Generator&, const EventSet&, const Generator&, Generator&).
185 * Controllability attributes are taken from the plant argument.
186 * If the result is specified as a System, attributes will be copied
187 * from the plant argument.
188 *
189 *
190 * @param rPlantGen
191 * Plant System
192 * @param rSpecGen
193 * Specification Generator
194 * @param rResGen
195 * Reference to resulting Generator, the
196 * minimal restrictive nonblocking supervisor
197 *
198 * @exception Exception
199 * Alphabets of generators don't match (id 100)
200 * plant nondeterministic (id 201)
201 * spec nondeterministic (id 203)
202 * plant and spec nondeterministic (id 204)
203 *
204 * @ingroup SynthesisPlugIn
205 */
206extern FAUDES_API void SupCon(
207 const System& rPlantGen,
208 const Generator& rSpecGen,
209 Generator& rResGen);
210
211
212
213/**
214 * Supremal Controllable and Closed Sublanguage
215 *
216 * Given a closed plant language L and a closed specification E, this function
217 * computes a realisation of the supremal controllable and closed sublanguage
218 * of L^E. Arguments and result generate the respective language (i.e. marked
219 * languages are not considered.)
220 *
221 * Parameter restrictions: both generators must be deterministic and
222 * have the same alphabet.
223 *
224 * @param rPlantGen
225 * Plant L generated by rPlantGen
226 * @param rCAlph
227 * Controllable events
228 * @param rSpecGen
229 * Specification E generated rSpecGen
230 * @param rResGen
231 * Reference to resulting Generator, the
232 * minimal restrictive supervisor
233 *
234 * @exception Exception
235 * - alphabets of generators don't match (id 100)
236 * - plant nondeterministic (id 201)
237 * - spec nondeterministic (id 203)
238 * - plant and spec nondeterministic (id 204)
239 *
240 * @ingroup SynthesisPlugIn
241 */
242extern FAUDES_API void SupConClosed(
243 const Generator& rPlantGen,
244 const EventSet& rCAlph,
245 const Generator& rSpecGen,
246 Generator& rResGen);
247
248
249/**
250 * Supremal Controllable and Closed Sublanguage.
251 *
252 * This is the RTI wrapper for
253 * SupCon(const Generator&, const EventSet&, const Generator&, Generator&).
254 *
255 * Controllability attributes are taken from the plant argument.
256 * If the result is specified as a System, attributes will be copied
257 * from the plant argument.
258 *
259 * @param rPlantGen
260 * Plant System
261 * @param rSpecGen
262 * Specification Generator
263 * @param rResGen
264 * Reference to resulting Generator, the
265 * minimal restrictive supervisor
266 *
267 * @exception Exception
268 * Alphabets of generators don't match (id 100)
269 * plant nondeterministic (id 201)
270 * spec nondeterministic (id 203)
271 * plant and spec nondeterministic (id 204)
272 *
273 * @ingroup SynthesisPlugIn
274 */
275extern FAUDES_API void SupConClosed(
276 const System& rPlantGen,
277 const Generator& rSpecGen,
278 Generator& rResGen);
279
280/**
281 * Supremal Controllable and Closed Sublanguage.
282 *
283 * Implementation of SupConClosed.
284 *
285 * See "C.G CASSANDRAS AND S. LAFORTUNE. Introduction to Discrete Event
286 * Systems. Kluwer, 1999." for base algorithm.
287 *
288 * This version sets up a "composition map" provided as a reference parameter.
289 * The map is restricted such that its range matches the resulting supervisor.
290 *
291 * @param rPlantGen
292 * Plant Generator
293 * @param rCAlph
294 * Controllable events
295 * @param rSpecGen
296 * Specification Generator
297 * @param rReverseCompositionMap
298 * std::map< std::pair<Idx,Idx>, Idx> as in the parallel composition function
299 * @param rResGen
300 * Reference to resulting Generator, the
301 * minimal restrictive supervisor
302 *
303 * @exception Exception
304 * - alphabets of generators don't match (id 100)
305 * - plant nondeterministic (id 201)
306 * - spec nondeterministic (id 203)
307 * - plant and spec nondeterministic (id 204)
308 */
309extern FAUDES_API void SupConClosed(
310 const Generator& rPlantGen,
311 const EventSet& rCAlph,
312 const Generator& rSpecGen,
313 std::map< std::pair<Idx,Idx>,Idx >& rReverseCompositionMap,
314 Generator& rResGen);
315
316
317
318/**
319 * Nonblocking Supremal Controllable Sublanguage (internal function)
320 *
321 * This version of SupCon performs no consistency test of the given parameter.
322 * It set's up a "composition map" as in the parallel composition, however,
323 * the map may still contain states that have been removed from the result
324 * to obtain controllability.
325 *
326 * @param rPlantGen
327 * Plant Generator
328 * @param rCAlph
329 * Controllable events
330 * @param rSpecGen
331 * Specification Generator
332 * @param rReverseCompositionMap
333 * std::map< std::pair<Idx,Idx>, Idx> as in the parallel composition function
334 * @param rResGen
335 * Reference to resulting System, the
336 * minimal restrictive nonblocking supervisor
337 *
338 * @exception Exception
339 * - alphabets of generators don't match (id 100)
340 * - plant nondeterministic (id 201)
341 * - spec nondeterministic (id 203)
342 * - plant and spec nondeterministic (id 204)
343 */
344extern FAUDES_API void SupConUnchecked(
345 const Generator& rPlantGen,
346 const EventSet& rCAlph,
347 const Generator& rSpecGen,
348 std::map< std::pair<Idx,Idx>,Idx >& rReverseCompositionMap,
349 Generator& rResGen);
350
351
352
353/**
354 * Supremal Controllable Sublangauge (internal function)
355 *
356 * Indentifies and deletes "critical" states in the supervisor candidate,
357 * in order to achieve controllability.
358 * This version of SupConClosed performs no consistency test of the given parameter.
359 * In order to obtain indeed the supremal sublanguage, the state space of the candidate
360 * must be rich enough to discriminate plant states. This can be done by e.g. setting
361 * up the candidate SupConParallel.
362 *
363 * In general, the result is blocking.
364 *
365 * @param rPlantGen
366 * Plant generator
367 * @param rCAlph
368 * Controllable events
369 * @param rSupCandGen
370 * Supervisor candidate generator
371 *
372 *
373 */
375 const Generator& rPlantGen,
376 const EventSet& rCAlph,
377 Generator& rSupCandGen);
378
379
380/**
381 * Parallel composition optimized for the purpose of SupCon (internal function)
382 *
383 * Composition stops at transition paths that violate the specification
384 * by uncontrollable plant transitions.
385 *
386 * This internal function performs no consistency test of the given parameter.
387 * It set's up a "composition map" as in the product composition, however,
388 * the map may still contain states that have been removed from the result
389 * to obtain controllability.
390 *
391 * @param rPlantGen
392 * Plant Generator
393 * @param rCAlph
394 * Uncontrollable Events
395 * @param rSpecGen
396 * Specification Generator
397 * @param rReverseCompositionMap
398 * std::map< std::pair<Idx,Idx>, Idx> as in the parallel composition function
399 * @param rResGen
400 * Reference to resulting Generator, the
401 * less restrictive supervisor
402 */
403extern FAUDES_API void SupConProduct(
404 const Generator& rPlantGen,
405 const EventSet& rCAlph,
406 const Generator& rSpecGen,
407 std::map< std::pair<Idx,Idx>, Idx>& rReverseCompositionMap,
408 Generator& rResGen);
409
410/**
411 * Controllability (internal function)
412 *
413 * Checks if language of specification h is controllable with respect to
414 * language of generator g. Only for deterministic plant + spec.
415 * Controllable event set has to be given as parameter.
416 *
417 * This internal function performs no consistency test of the given parameter.
418 *
419 * @param rPlantGen
420 * Plant generator
421 * @param rCAlph
422 * Controllable events
423 * @param rSpecGen
424 * Specification generator
425 * @param rCriticalStates
426 * Set of critical states
427 *
428 * @exception Exception
429 * - alphabets of generators don't match (id 100)
430 * - plant generator nondeterministic (id 201)
431 * - specification generator nondeterministic (id 203)
432 * - plant & spec generator nondeterministic (id 204)
433 *
434 * @return
435 * true / false
436 */
438 const Generator& rPlantGen,
439 const EventSet& rCAlph,
440 const Generator& rSpecGen,
441 StateSet& rCriticalStates);
442
443
444/**
445 * Helper function for IsControllable. The state given as "current" is
446 * considered critical. Itself and all uncontrollable predecessor states
447 * are added to the set "rCriticalStates".
448 *
449 * @param rCAlph
450 * Set of controllable events
451 * @param rtransrel
452 * Reverse sorted transition relation
453 * @param rCriticalStates
454 * Set of critical states in composition generator
455 * @param current
456 * Current state
457 */
459 const EventSet& rCAlph,
460 TransSetX2EvX1& rtransrel,
461 StateSet& rCriticalStates,
462 Idx current);
463
464
465
466/**
467 * Consistency check for controlproblem input data.
468 * Tests whether alphabets match and generators are deterministic.
469 *
470 * @param rPlantGen
471 * Plant generator
472 * @param rCAlph
473 * Controllable events
474 * @param rSpecGen
475 * Specification generator
476 *
477 * @exception Exception
478 * - lphabets of generators don't match (id 100)
479 * - plant generator nondeterministic (id 201)
480 * - specification generator nondeterministic (id 203)
481 * - plant and spec generator nondeterministic (id 204)
482 */
484 const Generator& rPlantGen,
485 const EventSet& rCAlph,
486 const Generator& rSpecGen);
487
488/**
489 * Consistency check for controlproblem input data.
490 * Tests whether alphabets match and generators are deterministic.
491 *
492 * @param rPlantGen
493 * Plant generator
494 * @param rCAlph
495 * Controllable events
496 * @param rOAlph
497 * Observable events
498 * @param rSpecGen
499 * Specification generator
500 *
501 * @exception Exception
502 * - lphabets of generators don't match (id 100)
503 * - plant generator nondeterministic (id 201)
504 * - specification generator nondeterministic (id 203)
505 * - plant and spec generator nondeterministic (id 204)
506 */
508 const Generator& rPlantGen,
509 const EventSet& rCAlph,
510 const EventSet& rOAlph,
511 const Generator& rSpecGen);
512
513
514
515// legacy interface (pre v2.33d)
516extern FAUDES_API void SupConNB(
517 const Generator& rPlantGen,
518 const EventSet& rCAlph,
519 const Generator& rSpecGen,
520 Generator& rResGen);
521extern FAUDES_API void SupConNB(
522 const System& rPlantGen,
523 const Generator& rSpecGen,
524 Generator& rResGen);
525
526
527} // namespace faudes
528
529#endif
530
531
#define FAUDES_API
IndexSet StateSet
TTransSet< TransSort::X2EvX1 > TransSetX2EvX1
NameSet EventSet
vGenerator Generator
TcGenerator< AttributeVoid, AttributeVoid, AttributeCFlags, AttributeVoid > System
bool IsControllable(const Generator &rPlantGen, const EventSet &rCAlph, const Generator &rSupCandGen)
void SupCon(const Generator &rPlantGen, const EventSet &rCAlph, const Generator &rSpecGen, Generator &rResGen)
void SupConClosed(const Generator &rPlantGen, const EventSet &rCAlph, const Generator &rSpecGen, Generator &rResGen)
uint32_t Idx
bool IsControllableUnchecked(const Generator &rPlantGen, const EventSet &rCAlph, const Generator &rSupCandGen, StateSet &rCriticalStates)
void SupConNB(const Generator &rPlantGen, const EventSet &rCAlph, const Generator &rSpecGen, Generator &rResGen)
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)
void SupConUnchecked(const Generator &rPlantGen, const EventSet &rCAlph, const Generator &rSpecGen, std::map< std::pair< Idx, Idx >, Idx > &rCompositionMap, Generator &rResGen)
void TraverseUncontrollableBackwards(const EventSet &rCAlph, TransSetX2EvX1 &rtransrel, StateSet &rCriticalStates, Idx current)

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