Skip to content
Snippets Groups Projects
Commit cda9fc53 authored by Kais Klai's avatar Kais Klai
Browse files

modif update lg

parent 437908fa
No related branches found
No related tags found
No related merge requests found
Pipeline #10700 passed with stage
......@@ -307,7 +307,9 @@ void ComputeAbstractPaths(const std::string& net_file, int bound, bool only_sog,
pn_sog.GenerateSOG(sog);
auto sog_time = GetTime() - start_sog_time;
std::cout << " done\nTime for computing SOG: " << sog_time << " seconds\n";
std::cout<<"--------------------"<<std::endl;
sog.PrintCompleteInformation();
std::cout<<"--------------------"<<std::endl;
auto elapsed_time = GetTime() - start_time;
std::cout << "\nTotal time: " << elapsed_time << " seconds\n";
......@@ -400,7 +402,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();
std::cout << "\nGenerating regex from the SOG ... ";
auto start_regex_time = GetTime();
const std::string language = pn_sog.GenerateRegExp(&sog).begin()->first;
......@@ -442,6 +444,7 @@ void SaveObsPathsAndWeights(const string& net_file, int bound,
// print output
PrintOutputObsWeights(model, sog, obs_trans, obs_paths, weight_obs_paths,
output_file_prefix);
}
/******************************************************************************
......
......@@ -394,7 +394,6 @@ int PetriNetSOG::ComputeSingleMaxWeight(const Aggregate *aggr, const int in,
<< transitions[out].name << '\n';
bdd source = SearchExitPoints(aggr->bdd_state, out);
const bdd dest = relation[in]((aggr->GetPredecessorsOfTrans(in))->bdd_state);
// backtracking from source until dest
bdd inputPoints = dest & source;
int counter = 0;
......@@ -668,17 +667,21 @@ std::string JoinSequencesOfLg(const Lg &lg) {
void UpdateLanguage(const Aggregate *s, const int s0, std::map<int, Lg> &lg_map,
std::set<int> &visited) {
if (visited.find(s->id()) != visited.end()) {
Lg updated_lg = {};
for (const LgElement &e : lg_map[s->id()]) {
const std::string seq_e = e.first;
const Aggregate *state_e = e.second;
if (state_e != nullptr && state_e->id() != s0) {
UpdateLanguage(state_e, s0, lg_map, visited);
ConcatSequences(seq_e, lg_map[state_e->id()], updated_lg);
} else {
updated_lg.push_back(e);
}
if(visited.find(state_e->id()) != visited.end())
{
if (state_e != nullptr && state_e->id() != s0) {
UpdateLanguage(state_e, s0, lg_map, visited);
ConcatSequences(seq_e, lg_map[state_e->id()], updated_lg);
} else {
updated_lg.push_back(e);
}
}
}
lg_map[s->id()] = updated_lg;
}
......@@ -730,11 +733,15 @@ Lg PetriNetSOG::RegularExpressionGeneration(std::vector<Aggregate *> &st,
if (!cy.empty()) {
std::string seq = JoinSequencesOfLg(cy);
if (!cy_compl.empty()) {
Lg updated_lg = {};
for (const LgElement &e : cy_compl) {
updated_lg.push_back({seq + e.first, e.second});
}
lg_map[cur->id()] = updated_lg;
lg_map[cur->id()]={};
//Lg updated_lg = {};
//for (const LgElement &e : cy_compl) {
// updated_lg.push_back({seq + e.first, e.second});
//}
for (const LgElement &e : cy_compl) {
lg_map[cur->id()].push_back({seq + e.first, e.second});
}
//lg_map[cur->id()] = updated_lg;
} else {
lg_map[cur->id()] = {{seq, nullptr}};
}
......@@ -746,7 +753,6 @@ Lg PetriNetSOG::RegularExpressionGeneration(std::vector<Aggregate *> &st,
st.pop_back();
visited.insert(cur->id());
return lg_map[cur->id()];
}
......
......@@ -67,7 +67,7 @@ void SOG::ResetVisitedFlag(Aggregate *state, size_t counter) {
}
}
void SOG::PrintGraph(Aggregate *state, size_t counter) {
/*void SOG::PrintGraph(Aggregate *state, size_t counter) {
if (counter <= nb_states) {
std::cout << "\nSTATE NUMBER " << counter << " : \n";
state->visited = true;
......@@ -83,6 +83,23 @@ void SOG::PrintGraph(Aggregate *state, size_t counter) {
}
}
}
}*/
void SOG::PrintGraph(Aggregate *state, size_t counter) {
if (counter <= nb_states) {
std::cout << "\nSTATE NUMBER " << state->id() << " : \n";
state->visited = true;
PrintSuccessors(state);
getchar();
PrintPredecessors(state);
getchar();
for (const auto &successor : state->successors) {
if (!successor.state->visited) {
counter++;
PrintGraph(successor.state, counter);
}
}
}
}
void SOG::ExportGraphToDotFile(const std::string &filename) const {
......@@ -113,7 +130,7 @@ void SOG::ExportGraphToDotFile(const std::string &filename) const {
file.close();
}
void SOG::PrintSuccessors(const Aggregate *state) const {
/*void SOG::PrintSuccessors(const Aggregate *state) const {
std::cout << bddtable << state->bdd_state << '\n';
std::cout << "\n\tIts successors are ( " << state->successors.size()
......@@ -125,6 +142,19 @@ void SOG::PrintSuccessors(const Aggregate *state) const {
<< successor.state->bdd_state << '\n';
getchar();
}
}*/
void SOG::PrintSuccessors(const Aggregate *state) const {
std::cout << bddtable << state->id() << '\n';
std::cout << "\n\tIts successors are ( " << state->successors.size()
<< " ):\n\n";
getchar();
for (const auto &successor : state->successors) {
std::cout << " \t- t" << successor.transition << " -> " << bddtable
<< successor.state->id() << '\n';
getchar();
}
}
void SOG::AddArc(Aggregate *from, Aggregate *to, const int t) {
......@@ -133,7 +163,7 @@ void SOG::AddArc(Aggregate *from, Aggregate *to, const int t) {
nb_edges++;
}
void SOG::PrintPredecessors(const Aggregate *state) const {
/*void SOG::PrintPredecessors(const Aggregate *state) const {
std::cout << "\n\tIts predecessors are ( " << state->predecessors.size()
<< " ):\n\n";
getchar();
......@@ -143,4 +173,15 @@ void SOG::PrintPredecessors(const Aggregate *state) const {
<< predecessor.state->bdd_state << '\n';
getchar();
}
}*/
void SOG::PrintPredecessors(const Aggregate *state) const {
std::cout << "\n\tIts predecessors are ( " << state->predecessors.size()
<< " ):\n\n";
getchar();
for (const auto &predecessor : state->predecessors) {
std::cout << " \t- t" << predecessor.transition << " ->" << bddtable
<< predecessor.state->id() << '\n';
getchar();
}
}
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