23 std::vector<ParityGameVertex> vertices;
28 while (!isalnum(ch)) is.get(ch);
35 if (!(is >> parity >> max_vertex))
return;
36 if (parity !=
"parity")
return;
37 vertices.reserve(max_vertex + 1);
40 while (is.get(ch) && ch !=
';') ch = 0;
44 while (!isalnum(ch)) is.get(ch);
51 if (!(is >> start >> vertex))
return;
52 if (start !=
"start")
return;
55 while (is.get(ch) && ch !=
';') ch = 0;
65 int prio_raw, player_raw;
67 if (!(is >>
id >> prio_raw >> player_raw))
break;
69 assert(prio_raw >= 0);
70 assert(prio_raw < 65536);
73 assert(player_raw == 0 || player_raw == 1);
76 if (prio > max_prio) max_prio = prio;
77 if (
id >= vertices.size()) vertices.resize(
id + 1, invalid);
83 assert(vertices[
id] == invalid);
85 vertices[id].player =
player;
86 vertices[id].priority = prio;
91 if (!(is >> succ))
break;
92 if (succ >= vertices.
size()) vertices.resize(succ + 1, invalid);
94 edges.push_back(std::make_pair(
id, succ));
98 bool quoted =
false, escaped =
false;
100 if (ch ==
'"' && !escaped) quoted = !quoted;
101 escaped = ch ==
'\\' && !escaped;
102 if ((ch ==
',' || ch ==
';') && !quoted)
break;
105 }
while (is && ch ==
',');
109 if (max_prio%2 == 1) ++max_prio;
112 std::vector<verti> vertex_map(vertices.size(),
NO_VERTEX);
114 for (
verti v = 0; v < (
verti)vertices.size(); ++v)
116 if (vertices[v] != invalid) {
117 vertices[used] = vertices[v];
118 vertex_map[v] = used++;
121 if (used < (
verti)vertices.size())
124 vertices.erase(vertices.begin() + used, vertices.end());
127 for ( StaticGraph::edge_list::iterator it = edges.begin();
128 it != edges.end(); ++it )
130 it->first = vertex_map[it->first];
131 it->second = vertex_map[it->second];
138 for (std::size_t n = 0; n < vertices.size(); ++n)
140 assert(vertices[n] != invalid);
155 if (max_prio%2 == 1) --max_prio;
158 os <<
"parity " << (
long long)
graph_.
V() - 1 <<
";\n";
166 while (it != end) os <<
',' << *it++;
173 const std::string &rewrite_strategy )
176 load_pbes(pbes, file_path);
177 assign_pbes(pbes, goal_vertex, edge_dir, rewrite_strategy);
182 const std::string &rewrite_strategy)
189 if (goal_vertex) *goal_vertex = 2;
197 verti begin = 0, end = 3;
198 for (
verti v = begin; v < end; ++v)
201 for ( std::set<std::size_t>::const_iterator it = deps.begin();
202 it != deps.end(); ++it )
206 if (w >= end) end = w + 1;
207 edges.push_back(std::make_pair(v - begin, w - begin));
213 for (
verti v = begin; v < end; ++v)
215 max_prio = std::max(max_prio, (
int)pgg.
get_priority(v));
219 reset(end - begin, max_prio + 1);
220 for (
verti v = begin; v < end; ++v)
238 is.read((
char*)&
d,
sizeof(
d));
248 os.write((
const char*)&
d_,
sizeof(
d_));
260 <<
"shape=" << (even ?
"diamond" :
"box") <<
", "
261 <<
"label=\"" <<
priority(v) <<
" (" << v <<
")\"]\n";
268 os << v <<
" -> " << *it;
278 os << *it <<
" -> " << v <<
";\n";
292 char l =
' ', r =
' ';
307 if (!s.empty() && s.at(v) !=
NO_VERTEX) os <<
" -> " << s.at(v);
std::size_t verti
type used to number vertices
priority_t priority(verti v) const
Player player(verti v) const
void reset(verti V, int d)
void write_pgsolver(std::ostream &os) const
void assign_pbes(mcrl2::pbes_system::pbes &pbes, verti *goal_vertex=0, StaticGraph::EdgeDirection edge_dir=StaticGraph::EDGE_BIDIRECTIONAL, const std::string &rewrite_strategy="jitty")
void read_pgsolver(std::istream &is, StaticGraph::EdgeDirection edge_dir=StaticGraph::EDGE_BIDIRECTIONAL)
void write_dot(std::ostream &os) const
void read_raw(std::istream &is)
void write_debug(const Strategy &s=Strategy(), std::ostream &os=std::cerr) const
void write_raw(std::ostream &os) const
void recalculate_cardinalities(verti num_vertices)
ParityGameVertex * vertex_
void read_pbes(const std::string &file_path, verti *goal_vertex=0, StaticGraph::EdgeDirection edge_dir=StaticGraph::EDGE_BIDIRECTIONAL, const std::string &rewrite_strategy="jitty")
std::vector< verti > Strategy
std::vector< std::pair< verti, verti > > edge_list
const_iterator succ_end(verti v) const
EdgeDirection edge_dir() const
void read_raw(std::istream &is)
const_iterator succ_begin(verti v) const
void write_raw(std::ostream &os) const
void assign(const StaticGraph &graph)
const_iterator pred_begin(verti v) const
const_iterator pred_end(verti v) const
const verti * const_iterator
size_type size() const
Returns the number of arguments of this term.
Class for generating a BES from a PBES. This BES can be interpreted as a graph corresponding to a par...
virtual operation_type get_operation(std::size_t index)
Returns the vertex type.
virtual std::size_t get_priority(std::size_t index)
Returns the priority of a vertex. The priority of the first equation is 0 if it is a maximal fixpoint...
virtual std::set< std::size_t > get_dependencies(std::size_t index)
Returns the successors of a vertex in the graph.
parameterized boolean equation system
rewrite_strategy parse_rewrite_strategy(const std::string &s)
standard conversion from string to rewrite strategy
A class for generating a parity game from a pbes.
IO routines for boolean equation systems.
player_t player
the vertex owner (i.e. next player to move)
priority_t priority
the priority of the vertex between 0 and d (exclusive).