Skip to content
Snippets Groups Projects
Commit 27010ee0 authored by Jaime Arias's avatar Jaime Arias
Browse files

refactor: some refactoring in the main.cpp

parent dced2859
No related branches found
No related tags found
No related merge requests found
Pipeline #10781 passed
......@@ -10,7 +10,6 @@
#include "Net.hpp"
#include "bdd.h"
#include "bvec.h"
#include "petri_net_sog.hpp"
// BDD initial values
......@@ -104,11 +103,11 @@ void SaveSOG(const SOG& sog, const string& sog_file) {
* @param weight_obs_paths vector of weights for the observable paths
* @param output_file_prefix file where the information will be saved
*/
void PrintOutputObsWeights(const RdP::net& model, SOG& sog,
const map<int, int>& obs_transitions,
const std::vector<std::vector<std::string>> obs_paths,
const std::vector<int>& weight_obs_paths,
const string& output_file_prefix) {
void PrintOutputObsWeights(
const RdP::net& model, SOG& sog, const map<int, int>& obs_transitions,
const std::vector<std::vector<std::string>>& obs_paths,
const std::vector<int>& weight_obs_paths,
const string& output_file_prefix) {
sog.PrintCompleteInformation();
cout << "\n# transition: " << model.transitions.size() << '\n';
cout << "# places: " << model.places.size() << '\n';
......@@ -117,26 +116,28 @@ void PrintOutputObsWeights(const RdP::net& model, SOG& sog,
std::string output_file = output_file_prefix + "_weights.txt";
cout << "\nSaving weights in " << output_file << '\n';
// save weights in the file
ofstream weight_file(output_file);
weight_file << "# path weights: " << weight_obs_paths.size() << '\n';
for (auto w_path : weight_obs_paths) {
if (w_path !=0)
weight_file << w_path << '\n';
if (w_path != 0) {
weight_file << w_path << '\n';
}
}
//weight_file << '\n';
// save observable paths in the folder
std::string output_obs_paths = output_file_prefix + "_obs_paths.txt";
ofstream obs_paths_file(output_obs_paths);
obs_paths_file << "# obs. paths: " << obs_paths.size(); //<< '\n';
obs_paths_file << "# obs. paths: " << obs_paths.size();
for (const auto& obs_p : obs_paths) {
if (obs_p.size()!=0){
for (auto t_label : obs_p) {
obs_paths_file << t_label << '_';
cout << t_label << "_";
}
if (!obs_p.empty()) {
for (const auto& t_label : obs_p) {
obs_paths_file << t_label << '_';
cout << t_label << "_";
}
}
obs_paths_file << '\n';
cout << '\n';
}
......@@ -239,7 +240,7 @@ void LoadTransitions(const RdP::net& model, const string& file,
* @param[out] obs_trans set of observable transitions
* @param[out] unobs_trans set of unobservable transitions
*/
void FindObservableTransitions(RdP::net& model, map<int, int>& obs_trans,
void FindObservableTransitions(const RdP::net& model, map<int, int>& obs_trans,
set<int>& unobs_trans) {
// compute the unobservable transitions of the model using the pattern
unobs_trans = model.calcul1();
......@@ -405,7 +406,7 @@ void SaveObsPathsAndWeights(const string& net_file, int bound,
auto sog_time = GetTime() - start_sog_time;
cout << " done\nTime for computing SOG: " << sog_time << " seconds\n";
// sog.PrintCompleteInformation();
// sog.PrintCompleteInformation();
std::cout << "\nGenerating regex from the SOG ... ";
auto start_regex_time = GetTime();
const std::string language = pn_sog.GenerateRegExp(&sog).begin()->first;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment