The application is a simulator designed to define a system of concurrent hybrid automata and simulate their behavior over time. The primary objective is to generate output files in .csv format containing the evolution of variables for these hybrid automatas.
- cmake (version 3.5 or newer)
sudo apt-get install cmake - make (version 4.3 or newer)
sudo apt-get install make - g++ compiler (version 11.0.3 or newer)
- ninja-build
sudo apt-get install ninja-build - qt (6 or superior)
https://www.qt.io/download-qt-installer-oss?hsCtaTracking=99d9dd4f-5681-48d2-b096-470725510d34%7C074ddad0-fdef-4e53-8aa8-5e8a876d6ab4
- cmake (version 3.28.0)
- make (version 3.81)
- MSVC (version 14.37.32822)
-
Clone the repository:
git clone https://github.com/AldeIT/Hybrid_Automata.git cd Hybrid_Automata -
Create and prepare Build Directory
mkdir build cd build export CMAKE_GENERATOR=Ninja export CMAKE_BUILD_TYPE=Debug export QT_QMAKE_EXECUTABLE=<path-to-qt-installation-directory>/Qt/<version>/gcc_64/bin/qmake export CMAKE_PREFIX_PATH=<path-to-qt-installation-directory>/Qt/<version>/gcc_64 export CMAKE_C_COMPILER=/usr/bin/gcc-11 (choose your own version) export CMAKE_CXX_COMPILER=/usr/bin/x86_64-linux-gnu-g++-11 (choose your own version) export CMAKE_CXX_FLAGS_INIT=-DQT_QML_DEBUG cmake -S <project-directory> -B <build-directory>
In case of an error regarding the "QT6Dir" variable or the "QT6ConfigCmake" file you will need to run the following command and then try again:
sudo apt-get install build-essential libgl1-mesa-dev -
Build and Run
cmake --build <build-directory> --target all ./main
-
Clone the repository:
git clone https://github.com/AldeIT/Hybrid_Automata.git cd Hybrid_Automata -
Create Build Directory and Compile
mkdir build cd build cmake .. cmake --build ./ --config Debug --target ALL_BUILD -j 10 cd Debug ./main.exe
The following image shows the program's startup window, where various operations can be performed. Let's examine the main ones in detail:
- It's possible to import a configuration file (using the IMPORT DATA button) of a previously modeled automaton and view it in the second window, namely Designer.
- It's possible to save the modeled project (using the SAVE DATA button).
- It's possible to import the trace of externally defined variables, if available (using the IMPORT INPUT FILE button)
- It's possible (and necessary) to set the variables that have been described in the automaton in the Design window through the appropriate value boxes.
In this second screen, we see how it's possible to model the automata that one wishes to declare.
- It's possible to add new automata by clicking the + button (after specifying their names in the appropriate label).
- Each automaton will be marked with a different color (up to 10 automata, then colors will repeat).
- The COMMANDS window indicates the commands for executing the main operations.
- Each node requires some information for its initialization, such as instructions, the node name, the node description, and the option to be set as a starter node.
- Each arrow (generated by selecting two circles and pressing the k key) requires a condition that can be inserted into the appropriate label.
When you need to define instructions to execute inside a node, you need to follow these rules:
- Simple Assignment
x = 5; #no particular rules just remember the ; at the end - Math Operation
x = 5 + a; #no particular rules just remember the ; at the end and make sure that the other variable exists - Differential Equation
x' = 5*x + a - 0.02; #the derivative is written with the ' after the variable and with no brackets such as "x'(t)", always remember the ; at the end
Delimit with parenthesis and if you need to use the and/or operator you can write conditions like this:
(x<19) & (x+5>=4) #and operator
(x<19) | (x+5>=4) #or operator
Some more examples:
((x<19) & (x+5>=4)) & (x+x<6)
(((x<19) | (x+5>=4)) & (2*x>=5)) | (x+1==0)
For a complete example with multiple automatas and various types of instructions and conditions you can read the Watertanks Example
In the main window, you can start the execution of the modeled automaton by clicking the RUN button after appropriately defining the "Final Time" and the "Delta" (execution step). During execution, the PAUSE/RESUME and STOP buttons will be enabled.
The system's evolution during the run is visible in the Designer screen, where, in addition to seeing in real-time which state the automaton is in, you can also consult the actual values of the calculated variables.
We notice how the states in which the automaton is during the execution flash and alternate between the classic color of the node and a darker version. Additionally, you can see at which step the execution is, through the label STEP.
You can start an execution in debug mode, which allows you to run step by step or to perform a designated number of steps. The advantage offered by this mode is the ability to precisely monitor the steps you are most interested in. The steps to start an execution in debug mode are as follows:
- Toggle the Debug Mode Switch on the Main screen
- Press the RUN button (which will lead the user to the designer screen).
- Click STEP to execute one step at a time or enter the number of steps to perform in the appropriate label and then click DO STEPS.
You can find the csv output file in the main directory under the name "export.csv". By default you will also find a "output.json" that contains the automata you have just run, be aware at every execution both the "output.json" and "export.csv" will be overwritten. And for every execution you'll have to close the two files before hitting the "Run" button.
Written in C++
Aldegheri Alessandro, Cipriani Michele, Venturi Davide, Vilotto Tommaso






