con_controllability.cpp
Go to the documentation of this file.
1 /** @file con_controllability.cpp Conditionalcontrollability */
2 
3 /*
4  * Implementation of the conditionally controllable algorithm
5  *
6  * Copyright (C) 2011 Tomas Masopust
7  *
8  */
9 
10 
11 #include "con_controllability.h"
12 #include <vector>
13 
14 namespace faudes {
15 
16 bool IsConditionalControllable(const GeneratorVector& specVect, const Generator& pk, const GeneratorVector& genVect, const Generator& gk, const EventSet& ACntrl) {
17  FD_DF("Conditionalcontrollability checking...");
18 
19  Idx i;
20 
21  // there must be the same number of parameters
22  if (specVect.Size() != genVect.Size()) {
23  std::stringstream errstr;
24  errstr << "The sizes of specVect and genVect are different.";
25  throw Exception("ConditionalControllability", errstr.str(), 201);
26  }
27 
28  // the generators must be deterministic
29  for (i = 0; i < specVect.Size(); i++) {
30  if (specVect.At(i).IsDeterministic() == false) {
31  std::stringstream errstr;
32  errstr << "Generators of specVect must be deterministic, but there is a nondeterministic one";
33  throw Exception("ConditionalControllability", errstr.str(), 201);
34  }
35  }
36 
37  if (pk.IsDeterministic() == false) {
38  std::stringstream errstr;
39  errstr << "Generator pk must be deterministic, but is nondeterministic";
40  throw Exception("ConditionalControllability", errstr.str(), 201);
41  }
42 
43  for (i = 0; i < genVect.Size(); i++) {
44  if (genVect.At(i).IsDeterministic() == false) {
45  std::stringstream errstr;
46  errstr << "Generators of genVect must be deterministic, but there is a nondeterministic one";
47  throw Exception("ConditionalControllability", errstr.str(), 201);
48  }
49  }
50 
51  if (gk.IsDeterministic() == false) {
52  std::stringstream errstr;
53  errstr << "Generator gk must be deterministic, but is nondeterministic";
54  throw Exception("ConditionalControllability", errstr.str(), 201);
55  }
56 
57  EventSet ekc; // the set of controllable events E_{k,c}
58  SetIntersection(gk.Alphabet(),ACntrl,ekc);
59 
60  // check whether the generators are nonblocking
61  if (IsNonblocking(pk) && IsNonblocking(gk) == false) {
62  std::stringstream errstr;
63  errstr << "Generators pk and gk must be nonblocking";
64  throw Exception("ConditionalControllability", errstr.str(), 201);
65  }
66 
67  // check if P_k(K) is controllable wrt L(G_k) and E_{k,c}
68  if (IsControllable(gk,ekc,pk) == false) {
69  return false;
70  }
71 
72  // check if P_{i+k}(K) is controllable wrt L(G_i)||\overline{P_k(K)} and E_{1+k,c}
73  Generator pkClosure = pk;
74  PrefixClosure(pkClosure);
75  for (i = 0; i < specVect.Size(); i++) {
76  Generator helpPlant;
77  Parallel(genVect.At(i),pkClosure,helpPlant);
78  EventSet uSet, Eikc;
79  SetUnion(genVect.At(i).Alphabet(),pk.Alphabet(),uSet);
80  SetIntersection(uSet,ACntrl,Eikc);
81  if (IsControllable(helpPlant,Eikc,specVect.At(i)) == false) {
82  return false;
83  }
84  if (IsNonblocking(genVect.At(i)) && IsNonblocking(specVect.At(i)) == false) {
85  std::stringstream errstr;
86  errstr << i << "th generator or specification projection is blocking";
87  throw Exception("ConditionalControllability", errstr.str(), 201);
88  }
89  }
90 
91  return true;
92 }
93 
94 
95 } // name space
96 
97 
98 
#define FD_DF(message)
Debug: optional report on user functions.
Faudes exception class.
Set of indices with symbolic names.
Definition: cfl_nameset.h:69
virtual const T & At(const Position &pos) const
Access element.
Idx Size(void) const
Get size of vector.
Base class of all FAUDES generators.
const EventSet & Alphabet(void) const
Return const reference to alphabet.
bool IsDeterministic(void) const
Check if generator is deterministic.
Conditional Controllability.
void SetUnion(const TBaseSet< T, Cmp > &rSetA, const TBaseSet< T, Cmp > &rSetB, TBaseSet< T, Cmp > &rRes)
Definition: cfl_baseset.h:1019
void SetIntersection(const TBaseSet< T, Cmp > &rSetA, const TBaseSet< T, Cmp > &rSetB, TBaseSet< T, Cmp > &rRes)
Definition: cfl_baseset.h:1049
bool IsConditionalControllable(const GeneratorVector &specVect, const Generator &pk, const GeneratorVector &genVect, const Generator &gk, const EventSet &ACntrl)
Conditionalcontrollability Checking Algorithm.
void PrefixClosure(Generator &rGen)
Prefix Closure.
void Parallel(const Generator &rGen1, const Generator &rGen2, Generator &rResGen)
Parallel composition.
bool IsControllable(const Generator &rPlantGen, const EventSet &rCAlph, const Generator &rSupCandGen)
Test controllability.
Definition: syn_supcon.cpp:718
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
bool IsNonblocking(const GeneratorVector &rGvec)

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen