hyb_1_hautomata.cpp
Go to the documentation of this file.
1/** @file hyb_1_hautomata.cpp
2
3Tutorial, hybrid systems plugin.
4This 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
15using namespace faudes;
16
17
18/** Run the tutorial */
19int 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
void Identity(int dim=-1)
void RowCount(int rc)
const Scalar::Type & At(int i, int j) const
void ColumnCount(int cc)
virtual bool Valid(void) const
const Polyhedron & Rate(Idx idx) const
const Polyhedron & Guard(const Transition &rTrans) const
const Polyhedron & Invariant(Idx idx) const
const LinearRelation & Reset(const Transition &rTrans) const
void Write(const Type *pContext=0) const
Transition TransitionByNames(const std::string &rX1, const std::string &rEv, const std::string &rX2) const
int main()

libFAUDES 2.34e --- 2026.03.16 --- c++ api documentaion by doxygen