mCRL2
Loading...
Searching...
No Matches
PredecessorLiftingStrategy.cpp
Go to the documentation of this file.
1// Copyright (c) 2009-2013 University of Twente
2// Copyright (c) 2009-2013 Michael Weber <michaelw@cs.utwente.nl>
3// Copyright (c) 2009-2013 Maks Verver <maksverver@geocities.com>
4// Copyright (c) 2009-2013 Eindhoven University of Technology
5//
6// Distributed under the Boost Software License, Version 1.0.
7// (See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9
11
13 const ParityGame &game, const SmallProgressMeasures &spm,
14 bool stack, int version )
15 : LiftingStrategy(), LiftingStrategy2(), spm_(spm), stack_(stack)
16{
18
19 // Initialize data
20 const verti V = game.graph().V();
21 queue_ = std::make_unique<verti[]>(V);
24
25 if (version == 1)
26 {
27 // v1 API requires explicit tracking of queued vertices.
28 queued_ = std::make_unique<bool[]>(V);
29 for (verti v = 0; v < V; ++v)
30 {
31 if (!spm_.is_top(v))
32 {
33 queued_[v] = true;
34 push(v);
35 }
36 }
37 }
38 else // version != 1
39 {
40 assert(version == 2);
41 queued_ = NULL;
42 }
43}
44
46{
47 mCRL2log(mcrl2::log::debug) << "push(" << v << ")" << std::endl;
48 queue_[queue_end_++] = v;
52}
53
55{
56 if (queue_size_ == 0) return NO_VERTEX;
57
58 // Remove an element from the queue
59 verti res;
60 if (stack_)
61 {
62 // Remove from the back of the queue
64 res = queue_[--queue_end_];
65 }
66 else
67 {
68 // Remove from the front of the queue
69 res = queue_[queue_begin_++];
71 }
73 mCRL2log(mcrl2::log::debug) << "pop() -> " << res << std::endl;
74 return res;
75}
76
78{
79 const StaticGraph &graph = spm_.game().graph();
80 for ( StaticGraph::const_iterator it = graph.pred_begin(v);
81 it != graph.pred_end(v); ++it )
82 {
83 verti u = *it;
84 if (!queued_[u] && !spm_.is_top(u))
85 {
86 queued_[u] = true;
87 push(u);
88 }
89 }
90}
91
93{
94 verti res = pop();
95 if (res != NO_VERTEX) queued_[res] = false;
96 return res;
97}
98
100{
101 return version == 1 || version == 2;
102}
103
105 const ParityGame &game, const SmallProgressMeasures &spm )
106{
107 return new PredecessorLiftingStrategy(game, spm, stack_, 1);
108}
109
111 const ParityGame &game, const SmallProgressMeasures &spm )
112{
113 return new PredecessorLiftingStrategy(game, spm, stack_, 2);
114}
std::size_t verti
type used to number vertices
Definition Graph.h:24
#define NO_VERTEX
Definition Graph.h:27
const StaticGraph & graph() const
Definition ParityGame.h:256
LiftingStrategy * create(const ParityGame &game, const SmallProgressMeasures &spm)
LiftingStrategy2 * create2(const ParityGame &game, const SmallProgressMeasures &spm)
PredecessorLiftingStrategy(const ParityGame &game, const SmallProgressMeasures &spm, bool stack, int version)
const SmallProgressMeasures & spm_
bool is_top(const verti vec[]) const
const ParityGame & game() const
EdgeDirection edge_dir() const
Definition Graph.h:185
verti V() const
Definition Graph.h:179
const_iterator pred_begin(verti v) const
Definition Graph.h:198
@ EDGE_PREDECESSOR
Definition Graph.h:87
const_iterator pred_end(verti v) const
Definition Graph.h:203
const verti * const_iterator
Definition Graph.h:66
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:391