hyb_3_abstraction.cpp
Go to the documentation of this file.
1 /** @file hyb_2_abstraction.cpp
2 
3 Tutorial, hybrid systems plugin.
4 This tutorial demonstrates how to compute a finite abstraction.
5 
6 @ingroup Tutorials
7 
8 @include hyb_3_abstraction.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  /** load from file */
24  LinearHybridAutomaton lha("data/hyb_lhautomaton.gen");
25 
26  // Report to console
27  std::cout << "################################\n";
28  std::cout << "# linear hybrid automaton from file: \n";
29  lha.Write();
30  std::cout << "################################\n";
31  std::cout << "# Valid() returns " << lha.Valid() << "\n";
32  std::cout << "################################\n";
33 
34 
35  // CompatibleStates
37  comp->InitialiseConstraint();
38 
39  // Experiment
40  Experiment* exp = new Experiment(lha.Alphabet());
41  exp->InitialStates(comp);
42 
43  // Do some refinements by node
44  exp->RefineAt(exp->Root());
45  exp->RefineAt(2);
46  exp->DWrite();
47 
48  // Do some refinements by event sequence
49  std::deque< Idx > seq;
50  seq.push_back(lha.EventIndex("north"));
51  seq.push_back(lha.EventIndex("south"));
52  seq.push_back(lha.EventIndex("north"));
53  seq.push_back(lha.EventIndex("south"));
54  seq.push_back(lha.EventIndex("north"));
55  seq.push_back(lha.EventIndex("south"));
56  seq.push_back(lha.EventIndex("north"));
57  seq.push_back(lha.EventIndex("south"));
58  exp->RefineSequence(seq);
59  exp->DWrite();
60 
61  // Do l-complete abstraction from scratch (time variant)
62  comp = new LhaCompatibleStates(lha);
63  comp->InitialiseConstraint();
64  exp = new Experiment(lha.Alphabet());
65  exp->InitialStates(comp);
66  LbdAbstraction tvabs;
67  tvabs.Experiment(exp);
68  tvabs.RefineUniformly(7);
69  tvabs.TvAbstraction().GraphWrite("tmp_abs3tv.png");
70 
71  // Do l-complete abstraction from scratch (time invariant)
72  comp = new LhaCompatibleStates(lha);
73  comp->InitialiseFull();
74  exp = new Experiment(lha.Alphabet());
75  exp->InitialStates(comp);
76  LbdAbstraction tivabs;
77  tivabs.Experiment(exp);
78  tivabs.RefineUniformly(7);
79  tivabs.TivAbstraction().GraphWrite("tmp_abs3tiv.png");
80 
81  // compose both for finest result
82  Generator result;
83  result.StateNamesEnabled(false);
84  Product(tvabs.TvAbstraction(),tivabs.TivAbstraction(),result);
85  StateMin(result,result);
86  result.GraphWrite("tmp_abs3.png");
87 
88  // done
89  return 0;
90 }
91 
92 
93 
Finite fragment of a computation tree.
Idx RefineSequence(const std::deque< Idx > &seq)
void DWrite(void) const
void RefineAt(Idx idx)
Idx Root(void) const
Navigate tree This interface is intended for external use.
void InitialStates(CompatibleStates *istates)
void RefineUniformly(unsigned int depth)
const Generator & TivAbstraction(void)
const Generator & TvAbstraction(void)
void Experiment(faudes::Experiment *exp)
const TaEventSet< EventAttr > & Alphabet(void) const
Return const reference to alphabet.
Generator with linear hybrid automata extensions.
virtual bool Valid(void) const
Check if generator is valid.
void Write(const Type *pContext=0) const
Write configuration data to console.
Definition: cfl_types.cpp:139
Base class of all FAUDES generators.
Idx EventIndex(const std::string &rName) const
Event index lookup.
bool StateNamesEnabled(void) const
Whether libFAUEDS functions are requested to generate state names.
void GraphWrite(const std::string &rFileName, const std::string &rOutFormat="", const std::string &rDotExec="dot") const
Produce graphical representation of this generator.
void StateMin(const Generator &rGen, Generator &rResGen)
State set minimization.
void Product(const Generator &rGen1, const Generator &rGen2, Generator &rResGen)
Product composition.
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