op_mc.cpp
Go to the documentation of this file.
1 /** @file op_mc.cpp
2 
3 Method to verify mutual controllability for two given generators.
4 A definition of mutual controllability is given in
5 S.-H. Lee and K. C. Wong, “Structural decentralised control of concurrent
6 DES,” European Journal of Control, vol. 35, pp. 1125-1134,2002.
7 */
8 
9 /* FAU Discrete Event Systems Library (libfaudes)
10 
11  Copyright (C) 2006 Bernd Opitz
12  Exclusive copyright is granted to Klaus Schmidt
13 
14  This library is free software; you can redistribute it and/or
15  modify it under the terms of the GNU Lesser General Public
16  License as published by the Free Software Foundation; either
17  version 2.1 of the License, or (at your option) any later version.
18 
19  This library is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  Lesser General Public License for more details.
23 
24  You should have received a copy of the GNU Lesser General Public
25  License along with this library; if not, write to the Free Software
26  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
27 
28 #include "op_mc.h"
29 
30 namespace faudes {
31 
32 bool IsMutuallyControllable(const System& rGen1, const System& rGen2) {
33  OP_DF("IsMutuallyControllable(" << rGen1.Name() << ", "
34  << rGen2.Name() << ")");
35  // helpers:
36  StateSet forbidden1;
37  StateSet forbidden2;
38  // Tha algorithm is implemented by the following function
39  return IsMutuallyControllable(rGen1, rGen2, forbidden1, forbidden2);
40 }
41 
42 
43 bool IsMutuallyControllable(const System& rGen1, const System& rGen2,
44  StateSet& rForbidden1, StateSet& rForbidden2) {
45  OP_DF("IsMutuallyControllable(" << rGen1.Name() << ", "
46  << rGen2.Name() << ", rForbidden1, rForbidden2)");
47  // algorithm:
48  // Compute the intersection of the generator alphabets
49  const EventSet alph12 = rGen1.Alphabet() * rGen2.Alphabet();
50  OP_DF("IsMutuallyControllable: shared events \"" << alph12.ToString()
51  << "\"");
52  // check for shared events: if there are no shared events, mutual controllability is fulfilled anyway.
53  if (alph12.Empty()) {
54  OP_DF("IsMutuallyControllable: shared alphabet empty. "
55  << "terminating successful");
56  return true;
57  }
58  // check for shared uncontrollable events
59  const EventSet ualph12 = rGen1.UncontrollableEvents() * rGen2.UncontrollableEvents();
60  OP_DF("IsMutuallyControllable: shared uncontrollable events \""
61  << ualph12.ToString() << "\"");
62  // if there are no shared uncontrollable events, mutual controllability is fulfilled anyway.
63  if (ualph12.Empty()) {
64  OP_DF("IsMutuallyControllable: shared uncontrollable alphabet empty "
65  << "terminating successful");
66  return true;
67  }
68  // prepare results
69  bool result1;
70  bool result2;
71  rForbidden1.Clear();
72  rForbidden2.Clear();
73  // The generator g will serve as the plant in the subsequent controllability evaluation
74  System g = rGen1.NewCGen();
75  // "plant": (P_21)^-1( P_12( L(G_2) )) is the language generated by g
76  aProject(rGen2, alph12, g);
77  InvProject(g, rGen1.Alphabet());
78  // The set of controllable events for the controllability test is alphabet of rGen1 - the shared uncontrollable events
79  // mutual controllability test of rGen2 w.r.t. rGen1.
80  result1 = IsControllable(g, (rGen1.Alphabet() - ualph12), rGen1, rForbidden1);
81  // print uncontrollable states if result is negative
82  if (result1 == false) {
83  OP_DF("IsMutuallyControllable(" << rGen1.Name() << ", " << rGen2.Name()
84  << "): uncontrollable states: " << rForbidden1.ToString());
85  }
86  // "plant": (P_12)^-1( P_21( L(G_1) )) is the language generated by g
87  aProject(rGen1, alph12, g);
88  InvProject(g, rGen2.Alphabet());
89  // The set of controllable events for the controllability test is alphabet of rGen2 - the shared uncontrollable events
90  // mutual controllability test of rGen1 w.r.t. rGen2.
91  result2 = IsControllable(g, (rGen2.Alphabet() - ualph12), rGen2, rForbidden2);
92  // print uncontrollable states if result is negative
93  if (result2 == false) {
94  OP_DF("IsMutuallyControllable(" << rGen1.Name() << ", " << rGen2.Name()
95  << "): uncontrollable states: " << rForbidden2.ToString());
96  }
97 
98  if (result1 && result2) {
99  OP_DF("IsMutuallyControllable: fulfilled");
100  }
101  else {
102  OP_DF("IsMutuallyControllable: failed");
103  }
104 
105  return (result1 && result2);
106 }
107 
108 // RTI wrapper
109 void IsMutuallyControllable(const System& rGen1, const System& rGen2, bool& rRes) {
110  rRes=IsMutuallyControllable(rGen1, rGen2);
111 }
112 
113 } // namespace faudes
114 
Set of indices.
Definition: cfl_indexset.h:78
Set of indices with symbolic names.
Definition: cfl_nameset.h:69
const TaEventSet< EventAttr > & Alphabet(void) const
Return const reference to alphabet.
Generator with controllability attributes.
EventSet UncontrollableEvents(void) const
Get EventSet with uncontrollable events.
TcGenerator NewCGen(void) const
Construct on stack.
std::string ToString(const std::string &rLabel="", const Type *pContext=0) const
Write configuration data to a string.
Definition: cfl_types.cpp:169
void Name(const std::string &rName)
Set the generator's name.
bool Empty(void) const
Test whether if the TBaseSet is Empty.
Definition: cfl_baseset.h:1824
virtual void Clear(void)
Clear all set.
Definition: cfl_baseset.h:1902
void InvProject(Generator &rGen, const EventSet &rProjectAlphabet)
Inverse projection.
void aProject(const Generator &rGen, const EventSet &rProjectAlphabet, Generator &rResGen)
Deterministic projection.
bool IsMutuallyControllable(const System &rGen1, const System &rGen2)
Verification of mutual controllability.
Definition: op_mc.cpp:32
bool IsControllable(const Generator &rPlantGen, const EventSet &rCAlph, const Generator &rSupCandGen)
Test controllability.
Definition: syn_supcon.cpp:718
libFAUDES resides within the namespace faudes.
#define OP_DF(expr)
Definition: op_debug.h:31
Method to verify mutual controllability for two given generators.

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