mCRL2
Loading...
Searching...
No Matches
pbessolve_attractors.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
11
12#ifndef MCRL2_PBES_PBESSOLVE_ATTRACTORS_H
13#define MCRL2_PBES_PBESSOLVE_ATTRACTORS_H
14
16
17namespace mcrl2 {
18
19namespace pbes_system {
20
21// Does not set a strategy
23{
25 {}
26};
27
28// Puts strategy annotations in the strategy attributes of the nodes of graph G
29template <typename StructureGraph>
31{
32 const StructureGraph& G;
33
34 explicit global_strategy(const StructureGraph& G_)
35 : G(G_)
36 {}
37
39 {
40 if (v == undefined_vertex())
41 {
42 mCRL2log(log::debug) << "Error: undefined strategy for node " << u << std::endl;
43 }
44 mCRL2log(log::debug) << " set tau[" << u << "] = " << v << std::endl;
45 G.find_vertex(u).strategy = v;
46 }
47};
48
49// Puts strategy annotations in tau[alpha]
51{
52 std::array<strategy_vector, 2>& tau;
53 std::size_t alpha;
54
55 local_strategy(std::array<strategy_vector, 2>& tau_, std::size_t alpha_)
56 : tau(tau_), alpha(alpha_)
57 {}
58
60 {
61 if (v == undefined_vertex())
62 {
63 mCRL2log(log::debug) << "Error: undefined strategy for node " << u << std::endl;
64 }
65 mCRL2log(log::debug) << " set tau" << alpha << "[" << u << "] = " << v << std::endl;
66 tau[alpha][u] = v;
67 }
68};
69
70// Combination of global and local strategy
71template <typename StructureGraph>
73{
76
77 global_local_strategy(const StructureGraph& G, std::array<strategy_vector, 2>& tau, std::size_t alpha)
78 : global(G), local(tau, alpha)
79 {}
80
82 {
83 global.set_strategy(u, v);
84 local.set_strategy(u, v);
85 }
86};
87
88// Returns true if succ(u) \subseteq A
89template <typename StructureGraph, typename VertexSet>
90bool includes_successors(const StructureGraph& G, typename StructureGraph::index_type u, const VertexSet& A)
91{
92 for (auto v: G.successors(u))
93 {
94 if (!A.contains(v))
95 {
96 return false;
97 }
98 }
99 return true;
100}
101
102// Returns pred(A) \ A
103template <typename StructureGraph>
104deque_vertex_set exclusive_predecessors(const StructureGraph& G, const vertex_set& A)
105{
106 // put all predecessors of elements in A in todo
107 deque_vertex_set todo(G.all_vertices().size());
108 for (auto u: A.vertices())
109 {
110 for (auto v: G.predecessors(u))
111 {
112 if (!A.contains(v))
113 {
114 todo.insert(v);
115 }
116 }
117 }
118 return todo;
119}
120
121// Inserts pred(u) \ A into todo
122template <typename StructureGraph>
123void insert_predecessors(const StructureGraph& G, structure_graph::index_type u, const vertex_set& A, deque_vertex_set& todo)
124{
125 for (auto v: G.predecessors(u))
126 {
127 if (!A.contains(v))
128 {
129 todo.insert(v);
130 }
131 }
132}
133
134// Computes an attractor set, by extending A.
135// alpha = 0: disjunctive
136// alpha = 1: conjunctive
137// StructureGraph is either structure_graph or simple_structure_graph
138// Strategy is either no_strategy, global_strategy, local_strategy or global_local_strategy
139template <typename StructureGraph, typename Strategy>
140vertex_set attr_default_generic(const StructureGraph& G, vertex_set A, std::size_t alpha, Strategy tau)
141{
143
144 while (!todo.is_empty())
145 {
146 // N.B. Use a breadth first search, to minimize counter examples
147 auto u = todo.pop_front();
148
149 if (G.decoration(u) == alpha || includes_successors(G, u, A))
150 {
151 tau.set_strategy(u, find_successor_in(G, u, A));
152 A.insert(u);
153 insert_predecessors(G, u, A, todo);
154 }
155 }
156
157 return A;
158}
159
160// Computes an attractor set, by extending A.
161// alpha = 0: disjunctive
162// alpha = 1: conjunctive
163// StructureGraph is either structure_graph or simple_structure_graph
164template <typename StructureGraph>
165vertex_set attr_default(const StructureGraph& G, vertex_set A, std::size_t alpha)
166{
168}
169
170// Variant of attr_default that does not set any strategies.
171template <typename StructureGraph>
172vertex_set attr_default_no_strategy(const StructureGraph& G, vertex_set A, std::size_t alpha)
173{
174 return attr_default_generic(G, A, alpha, no_strategy());
175}
176
177// Computes an attractor set, by extending A.
178// alpha = 0: disjunctive
179// alpha = 1: conjunctive
180// StructureGraph is either structure_graph or simple_structure_graph
181template <typename StructureGraph>
182vertex_set attr_default_with_tau(const StructureGraph& G, vertex_set A, std::size_t alpha, std::array<strategy_vector, 2>& tau)
183{
184 return attr_default_generic(G, A, alpha, global_local_strategy<StructureGraph>(G, tau, alpha));
185}
186
187} // namespace pbes_system
188
189} // namespace mcrl2
190
191#endif // MCRL2_PBES_PBESSOLVE_ATTRACTORS_H
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:391
constexpr unsigned int undefined_vertex()
deque_vertex_set exclusive_predecessors(const StructureGraph &G, const vertex_set &A)
bool includes_successors(const StructureGraph &G, typename StructureGraph::index_type u, const VertexSet &A)
vertex_set attr_default(const StructureGraph &G, vertex_set A, std::size_t alpha)
structure_graph::index_type find_successor_in(const StructureGraph &G, structure_graph::index_type u, const VertexSet &A)
vertex_set attr_default_generic(const StructureGraph &G, vertex_set A, std::size_t alpha, Strategy tau)
vertex_set attr_default_no_strategy(const StructureGraph &G, vertex_set A, std::size_t alpha)
void insert_predecessors(const StructureGraph &G, structure_graph::index_type u, const vertex_set &A, deque_vertex_set &todo)
vertex_set attr_default_with_tau(const StructureGraph &G, vertex_set A, std::size_t alpha, std::array< strategy_vector, 2 > &tau)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
add your file description here.
void insert(structure_graph::index_type u)
structure_graph::index_type pop_front()
global_local_strategy(const StructureGraph &G, std::array< strategy_vector, 2 > &tau, std::size_t alpha)
void set_strategy(structure_graph::index_type u, structure_graph::index_type v)
global_strategy< StructureGraph > global
global_strategy(const StructureGraph &G_)
void set_strategy(structure_graph::index_type u, structure_graph::index_type v)
void set_strategy(structure_graph::index_type u, structure_graph::index_type v)
std::array< strategy_vector, 2 > & tau
local_strategy(std::array< strategy_vector, 2 > &tau_, std::size_t alpha_)
static void set_strategy(structure_graph::index_type, structure_graph::index_type)
void insert(structure_graph::index_type u)
bool contains(structure_graph::index_type u) const
const std::vector< structure_graph::index_type > & vertices() const