hyb_4_controlA.cpp
Go to the documentation of this file.
1 /** @file hyb_4_control.cpp
2 
3 Tutorial, hybrid systems plugin. This tutorial demonstrates
4 how to compute a finite abstraction for the purpose of
5 control.
6 
7 @ingroup Tutorials
8 
9 @include hyb_4_Control.cpp
10 
11 */
12 
13 #include "libfaudes.h"
14 
15 // make the faudes namespace available to our program
16 using namespace faudes;
17 
18 
19 /** Run the tutorial */
20 int main() {
21 
22 
23 
24  /** load from file */
25  LinearHybridAutomaton lha("data/hyb_lhioautomaton.gen");
26 
27  // Report to console
28  std::cout << "################################\n";
29  std::cout << "# linear hybrid automaton from file: \n";
30  lha.Write();
31  std::cout << "################################\n";
32  std::cout << "# Valid() returns " << lha.Valid() << "\n";
33  std::cout << "################################\n";
34 
35  // get initial state
36  HybridStateSet istates;
37  StateSet::Iterator qit=lha.InitStatesBegin();
38  StateSet::Iterator qit_end=lha.InitStatesEnd();
39  for(;qit!=qit_end;++qit){
40  Polyhedron* poly = new Polyhedron(lha.InitialConstraint(*qit));
41  PolyIntersection(lha.StateSpace(),*poly);
42  PolyFinalise(*poly);
43  istates.Insert(*qit,poly);
44  }
45  std::cout << "################################\n";
46  std::cout << "# dumping initial states\n";
47  istates.DWrite(lha);
48  std::cout << "################################\n";
49 
50  /*
51 
52  // compute reachable states per event
53  std::map< Idx, HybridStateSet > ustates;
54  LhaReach(lha,istates,ustates);
55 
56  // dump successor states
57  std::cout << "################################\n";
58  std::cout << "# dumping successor u-states\n";
59  std::map< Idx, HybridStateSet >::iterator uit=ustates.begin();
60  std::map< Idx, HybridStateSet >::iterator uit_end=ustates.end();
61  for(;uit!=uit_end;++uit){
62  std::cout << "### event " << lha.EventName(uit->first) << "\n";
63  uit->second.DWrite(lha);
64  }
65  std::cout << "################################\n";
66 
67  // compute reachable states per event
68  std::map< Idx, HybridStateSet > ystates;
69  istates.Assign(ustates[lha.EventIndex("u_north_west")]);
70  LhaReach(lha,istates,ystates);
71 
72  // dump successor states
73  std::cout << "################################\n";
74  std::cout << "# dumping successor y-states\n";
75  std::map< Idx, HybridStateSet >::iterator yit=ystates.begin();
76  std::map< Idx, HybridStateSet >::iterator yit_end=ystates.end();
77  for(;yit!=yit_end;++yit){
78  std::cout << "### event " << lha.EventName(yit->first) << "\n";
79  yit->second.DWrite(lha);
80  }
81  std::cout << "################################\n";
82 
83  // compute reachable states per event
84  istates.Assign(ystates[lha.EventIndex("y_north")]);
85  LhaReach(lha,istates,ustates);
86 
87  // dump successor states
88  std::cout << "################################\n";
89  std::cout << "# dumping successor u-states\n";
90  uit=ustates.begin();
91  uit_end=ustates.end();
92  for(;uit!=uit_end;++uit){
93  std::cout << "### event " << lha.EventName(uit->first) << "\n";
94  uit->second.DWrite(lha);
95  }
96  std::cout << "################################\n";
97 
98 
99  // compute reachable states per event
100  istates.Assign(ustates[lha.EventIndex("u_south_west")]);
101  LhaReach(lha,istates,ystates);
102 
103  // dump successor states
104  std::cout << "################################\n";
105  std::cout << "# dumping successor y-states\n";
106  yit=ystates.begin();
107  yit_end=ystates.end();
108  for(;yit!=yit_end;++yit){
109  std::cout << "### event " << lha.EventName(yit->first) << "\n";
110  yit->second.DWrite(lha);
111  }
112  std::cout << "################################\n";
113  */
114  // done
115  return 0;
116 }
117 
118 
119 
Set of states in an hybrid automata.
void DWrite(const LinearHybridAutomaton &lha)
inspect
void Insert(Idx q)
insert / erase (we take owvership of polyhedra)
Polyhedron in R^n.
Generator with linear hybrid automata extensions.
virtual bool Valid(void) const
Check if generator is valid.
const Polyhedron & InitialConstraint(Idx idx) const
Get initial constraint of state by index.
const Polyhedron & StateSpace(void) const
Get continuous statespace.
void Write(const Type *pContext=0) const
Write configuration data to console.
Definition: cfl_types.cpp:139
StateSet::Iterator InitStatesBegin(void) const
Iterator to Begin() of mInitStates.
StateSet::Iterator InitStatesEnd(void) const
Iterator to End() of mInitStates.
void PolyFinalise(const Polyhedron &fpoly)
convert PPL polyhedron back to faudes data structures; this is required if we manipulate a polyhedron...
Definition: hyb_compute.cpp:53
void PolyIntersection(const Polyhedron &poly, Polyhedron &res)
intersection
int main()
Run the tutorial.
Includes all libFAUDES headers, incl plugings
libFAUDES resides within the namespace faudes.

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