hyb_1_hautomata.cpp
Go to the documentation of this file.
1 /** @file hyb_1_hautomata.cpp
2 
3 Tutorial, hybrid systems plugin.
4 This tutorial demonstrates how to access hybrid automata attributes.
5 
6 @ingroup Tutorials
7 
8 @include hyb_1_hautomata.cpp
9 
10 */
11 
12 #include "libfaudes.h"
13 
14 // make the faudes namespace available to our program
15 using namespace faudes;
16 
17 
18 /** Run the tutorial */
19 int main() {
20 
21 
22 
23  // ///////////////////////////
24  //
25  // Section 1: parameter types
26  //
27  //
28 
29  // Construct a matrix from file
30  faudes::Matrix matA("data/hyb_matrix.txt");
31 
32  // Write matrix to file
33  matA.Write("tmp_hyb_1_matrix.txt");
34 
35  // Set to identity 5x5
36  matA.Identity(5);
37 
38  // Access entries, faudes style (here: copy column)
39  for(int i=0; i<matA.RowCount(); i++)
40  matA.At(i,1, matA.At(i,2));
41 
42  // Access entries, cosmetic operator (here: copy row)
43  for(int j=0; j<matA.ColumnCount(); j++)
44  matA(1,j) = matA(2,j);
45 
46  // Write matrix to console
47  matA.Write();
48 
49  // Report to console
50  std::cout << "################################\n";
51  std::cout << "# Some matrix: \n";
52  matA.Write();
53  std::cout << "################################\n";
54 
55  // Construct a polyhedron from file
56  faudes::Polyhedron polyP("data/hyb_polyhedron.txt");
57 
58  // Report to console
59  std::cout << "################################\n";
60  std::cout << "# Some polyhedron: \n";
61  polyP.Write();
62  std::cout << "################################\n";
63 
64  // ///////////////////////////
65  //
66  // Section 2: linear hybrid automata
67  //
68  //
69 
70  // Construct a linear hybrid automata from file
71  LinearHybridAutomaton lha("data/hyb_lhautomaton.gen");
72 
73  // Report to console
74  std::cout << "################################\n";
75  std::cout << "# linear hybrid automaton from file: \n";
76  lha.Write();
77  std::cout << "################################\n";
78  std::cout << "# Valid() returns " << lha.Valid() << "\n";
79  std::cout << "################################\n";
80 
81  // access some invariant
82  const faudes::Polyhedron& inv =lha.Invariant("Working");
83 
84  // access some rate
85  const faudes::Polyhedron& rhs =lha.Rate("Working");
86 
87  // access some reset
88  Transition ftrans=lha.TransitionByNames("Resting","alpha","Working");
89  const LinearRelation& res =lha.Reset(ftrans);
90 
91  // access some guard
92  const faudes::Polyhedron& grd =lha.Guard(ftrans);
93 
94  // Report to console
95  std::cout << "################################\n";
96  std::cout << "# state attributes\n";
97  inv.Write();
98  rhs.Write();
99  std::cout << "################################\n";
100  std::cout << "# transition attributes\n";
101  grd.Write();
102  res.Write();
103  std::cout << "################################\n";
104 
105 
106  // done
107  return 0;
108 }
109 
110 
111 
Linear relation on R^n.
Matrix of scalars.
Definition: hyb_parameter.h:64
void Identity(int dim=-1)
Set to identity matrix.
void RowCount(int rc)
Set dimension.
const Scalar::Type & At(int i, int j) const
Get entry.
void ColumnCount(int cc)
Set Dimension.
Polyhedron in R^n.
Generator with linear hybrid automata extensions.
virtual bool Valid(void) const
Check if generator is valid.
const Polyhedron & Rate(Idx idx) const
Get rate of state by index.
const Polyhedron & Guard(const Transition &rTrans) const
Get guard of a transition.
const Polyhedron & Invariant(Idx idx) const
Get invariant of state by index.
const LinearRelation & Reset(const Transition &rTrans) const
Get reset of a transition.
Triple (X1,Ev,X2) to represent current state, event and next state.
Definition: cfl_transset.h:57
void Write(const Type *pContext=0) const
Write configuration data to console.
Definition: cfl_types.cpp:139
Transition TransitionByNames(const std::string &rX1, const std::string &rEv, const std::string &rX2) const
Convebience function.
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