12#ifndef MCRL2_PBES_PBESINST_FIND_LOOPS_H
13#define MCRL2_PBES_PBESINST_FIND_LOOPS_H
15#include "mcrl2/pbes/pbesinst_lazy.h"
16#include "mcrl2/pbes/pbessolve_attractors.h"
17#include "mcrl2/pbes/simple_structure_graph.h"
18#include "mcrl2/pbes/structure_graph_builder.h"
40 if (w_.rank != data::undefined_index() && w_.rank != p)
44 auto i = visited.find(w);
45 if (i != visited.end())
53 if (w_.decoration == structure_graph::d_none || w_.decoration == p % 2)
55 for (structure_graph::index_type u: w_.successors)
57 if (u == v || find_loop(G, U, v, u, p, visited))
59 global_strategy<simple_structure_graph>(G).set_strategy(w, u == v ? v : u);
61 mCRL2log(log::debug) <<
" case 1: found a loop starting in " << v <<
" with current vertex w = " << w << std::endl;
74template <
class Container>
76 const Container& discovered,
82 mCRL2log(log::debug) <<
"Apply find loops (iteration " << iteration_count <<
") to graph:\n" << G << std::endl;
85 std::size_t insertion_count = 0;
87 std::size_t n = S[0].extent();
90 boost::dynamic_bitset<> todo_(n);
92 for (
const propositional_variable_instantiation& X: todo.elements())
94 structure_graph::index_type u = graph_builder.find_vertex(X);
109 std::unordered_map<structure_graph::index_type,
bool> visited;
113 for (structure_graph::index_type u: done.vertices())
115 const auto& u_ = G.find_vertex(u);
116 assert(u_.rank != data::undefined_index());
118 mCRL2log(log::debug) <<
"--- choose u = " << u << std::endl;
119 auto i = visited.find(u);
120 if (i != visited.end())
124 bool b = find_loop(G, done, u, u, u_.rank, visited);
128 if (u_.rank % 2 == 0)
133 mCRL2log(log::debug) <<
"Find loops: insert vertex " << u <<
" in S[0]" << std::endl;
140 mCRL2log(log::debug) <<
"Find loops: insert vertex " << u <<
" in S[1]" << std::endl;
145 S[0] = attr_default_with_tau(G, S[0], 0, tau);
149 S[1] = attr_default_with_tau(G, S[1], 1, tau);
153 mCRL2log(log::debug) <<
"Find loops: (iteration " << iteration_count <<
") inserted " << insertion_count <<
" vertices." << std::endl;
\brief A propositional variable instantiation
const vertex & find_vertex(index_type u) const
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
void find_loops(const simple_structure_graph &G, const Container &discovered, const pbesinst_lazy_todo &todo, std::array< vertex_set, 2 > &S, std::array< strategy_vector, 2 > &tau, std::size_t iteration_count, const detail::structure_graph_builder &graph_builder)
bool find_loop(const simple_structure_graph &G, const vertex_set &U, structure_graph::index_type v, structure_graph::index_type w, std::size_t p, std::unordered_map< structure_graph::index_type, bool > &visited)
index_type find_vertex(const pbes_expression &x) const
decoration_type decoration
void insert(structure_graph::index_type u)
bool contains(structure_graph::index_type u) const