Skip to content

Commit 3af6259

Browse files
committed
Add example commands on how to run Daalder
1 parent 094a5c1 commit 3af6259

7 files changed

Lines changed: 98 additions & 5 deletions

File tree

source/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ add_library(Source STATIC
8080
running_modes/predict_mode.cpp
8181
running_modes/regex_mode.h
8282
running_modes/regex_mode.cpp
83+
running_modes/load_sqldb_mode.h
84+
running_modes/load_sqldb_mode.cpp
8385
running_modes/running_mode_base.h
8486
running_modes/running_mode_base.cpp
8587
running_modes/search_mode.h

source/active_learning/readme.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,22 @@ seems not guaranteed anymore.
3636

3737
- To run valgrind on the Python interface, download the valgrind-python.supp file from the [cpython-github](https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp), and the run it using the flag
3838

39-
--suppressions=\[some path\]/valgrind-python.supp
39+
--suppressions=\[some path\]/valgrind-python.supp
40+
41+
# Daalder (or Ldot)
42+
43+
You can run Daalder (formerly Ldot) with these commands:
44+
45+
```sh
46+
# First load the strings a database.
47+
./flexfringe --ini ini/edsm.ini --mode load_sqldb --postgresql-tblname test_daalder20 test.dat --logpath test_daalder.log
48+
# Then you can learn the state machine from the stored traces using ldot.
49+
./flexfringe --ini ini/edsm.ini --mode active_learning --active_learning_algorithm ldot --al_oracle sqldb_sul_random_oracle --al_system_under_learning sqldb_sul --postgresql-tblname test_daalder20 '' --runs 1000001 --predicttype 1 --printblue 1 --printwhite 1 --logpath test_daalder.log --outputfile test_daalder
50+
```
51+
52+
For more configuration for connecting to PostGreSQL check documentation of PostGreSQL on connection string and set it with `--postgresql-connstring`.
53+
54+
For more details read:
55+
56+
* https://arxiv.org/abs/2406.07208
57+
* https://repository.tudelft.nl/record/uuid:40a1cb17-a46e-421e-a916-396ebaf3d7b1

source/running_mode_factory.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "interactive_mode.h"
2121
#include "predict_mode.h"
2222
#include "regex_mode.h"
23+
#include "load_sqldb_mode.h"
2324
#include "search_mode.h"
2425
#include "stream_mode.h"
2526
#include "subgraphextraction_mode.h"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @file regex_mode.cpp
3+
* @author Hielke Walinga
4+
* @brief
5+
* @version 0.1
6+
* @date 2024-12-19
7+
*
8+
* @copyright Copyright (c) 2024
9+
*
10+
*/
11+
12+
#include "load_sqldb_mode.h"
13+
#include "inputdatalocator.h"
14+
15+
#include <iostream>
16+
#include <ranges>
17+
#include "misc/sqldb.h"
18+
19+
void load_sqldb_mode::initialize(){
20+
// do nothing
21+
}
22+
23+
int load_sqldb_mode::run(){
24+
std::ifstream input_stream = get_inputstream();
25+
std::cout << "Selected to use the SQL database. Creating new inputdata object and loading traces.";
26+
abbadingo_inputdata id;
27+
inputdata_locator::provide(&id);
28+
auto my_sqldb = make_unique<psql::db>(POSTGRESQL_TBLNAME, POSTGRESQL_CONNSTRING);
29+
my_sqldb->load_traces(id, input_stream);
30+
31+
return EXIT_SUCCESS;
32+
}
33+
34+
void load_sqldb_mode::generate_output(){
35+
// do nothing
36+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @file regex_mode.h
3+
* @author Hielke Walinga
4+
* @brief
5+
* @version 0.1
6+
* @date 2024-12-19
7+
*
8+
* @copyright Copyright (c) 2024
9+
*
10+
*/
11+
12+
#ifndef _LOAD_SQLDB_MODE_H_
13+
#define _LOAD_SQLDB_MODE_H_
14+
15+
#include "running_mode_base.h"
16+
17+
#include "misc/sqldb.h"
18+
#include "misc/utils.h"
19+
20+
class load_sqldb_mode : public running_mode_base {
21+
public:
22+
void initialize() override;
23+
int run() override;
24+
void generate_output() override;
25+
};
26+
27+
#endif // _LOAD_SQLDB_MODE_H_

source/running_modes/running_mode_base.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
using namespace std;
2323

2424
/**
25-
* @brief Reads the entire input file all at once and stores it in input data.
25+
* @brief get the inputstream
2626
*/
27-
void running_mode_base::read_input_file() {
27+
ifstream running_mode_base::get_inputstream() const {
2828
ifstream input_stream(INPUT_FILE);
2929

3030
if(!input_stream) {
@@ -34,6 +34,14 @@ void running_mode_base::read_input_file() {
3434
} else {
3535
cout << "Using input file: " << INPUT_FILE << endl;
3636
}
37+
return input_stream;
38+
}
39+
40+
/**
41+
* @brief Reads the entire input file all at once and stores it in input data.
42+
*/
43+
void running_mode_base::read_input_file() {
44+
ifstream input_stream = get_inputstream();
3745

3846
bool read_csv = false;
3947
if(INPUT_FILE.ends_with(".csv")){
@@ -78,4 +86,4 @@ void running_mode_base::initialize(){
7886
void running_mode_base::generate_output(){
7987
cout << "Printing output to " << output_manager::get_outfile_path() << ".final" << endl;
8088
output_manager::output_manager::print_final_automaton(merger, ".final");
81-
}
89+
}

source/running_modes/running_mode_base.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class running_mode_base {
3333
state_merger* merger = nullptr; // must be set from within constructor
3434

3535
void read_input_file();
36+
std::ifstream get_inputstream() const;
3637

3738
public:
3839
~running_mode_base(){
@@ -56,4 +57,4 @@ class running_mode_base {
5657
virtual void generate_output();
5758
};
5859

59-
#endif
60+
#endif

0 commit comments

Comments
 (0)