mCRL2
Loading...
Searching...
No Matches
OldMaxMeasureLiftingStrategy.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
12/* NOTE: this code abuses the fact that verti is unsigned, making the top vector
13 strictly greater than vectors of other measures. */
14
16 const ParityGame &game, const SmallProgressMeasures &spm )
17 : LiftingStrategy(), spm_(spm),
18 queue_pos_(game.graph().V(), queue_.end())
19{
20 // Initialize queue
21 for (verti v = 0; v < game.graph().V(); ++v)
22 {
23 queue_pos_[v] =
24 queue_.insert(std::make_pair(std::vector<verti>(), v)).first;
25 }
26}
27
29{
30}
31
33{
34 std::vector<verti> m = vec(v);
35
36 // Add predecessors to queue
37 const StaticGraph &graph = spm_.game().graph();
38 for ( StaticGraph::const_iterator it = graph.pred_begin(v);
39 it != graph.pred_end(v); ++it )
40 {
41 verti u = *it;
42 queue_t::iterator it1 = queue_pos_[u];
43
44 /* Skip this predecessor if it is already queued with an
45 equal or greater weight. */
46 if (it1 != queue_.end() && it1->first >= m) continue;
47
48 // If we have an old entry in the queue, remove it first.
49 if (it1 != queue_.end()) queue_.erase(queue_pos_[u]);
50
51 // Add new entry to the queue
52 queue_pos_[u] = queue_.insert(std::make_pair(m, u)).first;
53 }
54}
55
57{
58 // Take a predecessor from the queue
59 verti v = NO_VERTEX;
60 queue_t::iterator it = queue_.end();
61 if (it != queue_.begin())
62 {
63 --it;
64 v = it->second;
65 queue_.erase(it);
66 queue_pos_[v] = queue_.end();
67 }
68 return v;
69}
70
72 const ParityGame &game, const SmallProgressMeasures &spm )
73{
74 return new OldMaxMeasureLiftingStrategy(game, spm);
75}
std::size_t verti
type used to number vertices
Definition Graph.h:24
#define NO_VERTEX
Definition Graph.h:27
LiftingStrategy * create(const ParityGame &game, const SmallProgressMeasures &spm)
OldMaxMeasureLiftingStrategy(const ParityGame &game, const SmallProgressMeasures &spm)
const SmallProgressMeasures & spm_
std::vector< queue_t::iterator > queue_pos_
std::vector< verti > vec(verti v)
const StaticGraph & graph() const
Definition ParityGame.h:256
const ParityGame & game() const
const_iterator pred_begin(verti v) const
Definition Graph.h:198
const_iterator pred_end(verti v) const
Definition Graph.h:203
const verti * const_iterator
Definition Graph.h:66