18 : lifts_attempted_(0), lifts_succeeded_(0), max_lifts_(max_lifts)
40 : game_(game), p_(player), stats_(stats),
41 vmap_(vmap), vmap_size_(vmap_size),
42 strategy_(game.graph().V(),
NO_VERTEX), dirty_(0)
44 assert(
p_ == 0 ||
p_ == 1);
50 for (std::size_t n = 0; n <
len_; ++n)
52 std::size_t prio = 2*n + 1 -
p_;
73 for (
verti v = 0; v < V; ++v)
85 <<
"vert" << (cnt == 1 ?
"ex" :
"ices") <<
" to top" << std::endl;
92 for (
verti v = 0; v < V; ++v)
105 if (dirty) ls.
push(v);
135 bool success =
false;
149 return std::make_pair(v, success);
238 assert(strat.size() == V);
239 for (
verti v = 0; v < V; ++v)
249 if (
is_top(v))
return false;
250 if (
is_top(vec2))
return true;
252 return comparison < 0 || (comparison <= 0 && carry);
257 if (
is_top(v))
return false;
266 if (comparison > 0 || (comparison >= 0 && !carry))
return false;
275 printf (
"%6d %c p=%d:", (
int)v,
278 (int)
game_.priority(v) );
285 for (
int p = 0; p <
game_.
d(); ++p)
287 printf(
" %d", (p%2 ==
p_) ? 0 :
vec(v)[p/2]);
296 for (
int p = 0; p <
game_.
d(); ++p) printf(
" %d", (p%2 ==
p_) ? 0 :
M_[p/2]);
305 for (
verti v = 0; v < graph.
V(); ++v)
309 for (
int p = 0; p <
game_.
d(); ++p)
311 if (p%2 ==
p_)
continue;
314 if (
vec(v)[p/2] >=
M_[p/2])
316 printf(
"%d-th component of SPM vector for vertex %d "
317 "out of bounds!\n", p, (
int)v );
323 printf(
"%d-th component of SPM vector for vertex %d "
324 "should be zero!\n", p/2, (
int)v );
330 bool all_ok =
true, one_ok =
false;
336 one_ok = one_ok || ok;
337 all_ok = all_ok && ok;
342 printf(
"order constraint not satisfied for vertex %d with "
358 const ParityGame &game, std::shared_ptr<LiftingStrategyFactory> lsf,
bool alternate,
361 stats_(stats), vmap_(vmap), vmap_size_(vmap_size)
372 std::vector<verti> won_by_odd;
378 std::unique_ptr<LiftingStrategy> ls(
lsf_->create(
game_, spm));
385 std::back_insert_iterator<std::vector<verti> >(won_by_odd) );
392 if (!won_by_odd.empty())
397 << won_by_odd.size() <<
" to solve for Odd..." << std::endl;
402 std::vector<verti> submap_data;
403 verti *submap = &won_by_odd[0];
404 std::size_t submap_size = won_by_odd.size();
407 submap_data = won_by_odd;
408 submap = &submap_data[0];
415 stats_, submap, submap_size );
416 std::unique_ptr<LiftingStrategy> ls(
lsf_->create(subgame, spm));
436 std::unique_ptr<SmallProgressMeasures> spm[2];
444 bool half_solved =
false;
448 << (player == 0 ?
"normal" :
"dual") <<
" game..." << std::endl;
449 std::unique_ptr<LiftingStrategy> ls(
lsf_->create(
game_, *spm[player]));
453 for (
long long work =
game_.
graph().
V(); work > 0 && !half_solved;
456 half_solved = spm[player]->solve_some(*ls) > 0;
468 std::unique_ptr<LiftingStrategy> ls(
lsf_->create(
game_, *spm[player]));
469 while (spm[player]->solve_some(*ls) == 0)
476 spm[0]->get_strategy(strategy);
477 spm[1]->get_strategy(strategy);
487 for (
verti v = 0; v < graph.
V(); ++v)
500 obsolete_edges.push_back(std::make_pair(v, *it));
508 obsolete_edges.push_back(std::make_pair(v, v));
521 const ParityGame &game, std::shared_ptr<LiftingStrategyFactory> lsf,
bool alternate,
524 stats, vmap, vmap_size)
531 std::vector<verti> won_by_odd;
537 std::unique_ptr<LiftingStrategy2> ls(
lsf_->create2(
game_, spm));
545 std::back_insert_iterator<std::vector<verti> >(won_by_odd) );
552 if (!won_by_odd.empty())
557 << won_by_odd.size() <<
" to solve for Odd..." << std::endl;
562 std::vector<verti> submap_data;
563 verti *submap = &won_by_odd[0];
564 std::size_t submap_size = won_by_odd.size();
567 submap_data = won_by_odd;
568 submap = &submap_data[0];
575 stats_, submap, submap_size );
576 std::unique_ptr<LiftingStrategy2> ls(
lsf_->create2(subgame, spm));
597 std::unique_ptr<SmallProgressMeasures> spm[2];
605 bool half_solved =
false;
609 std::unique_ptr<LiftingStrategy2> ls(
lsf_->create2(
game_, *spm[player]));
610 spm[player]->initialize_lifting_strategy(*ls);
612 for (
long long work =
game_.
graph().
V(); work > 0 && !half_solved;
615 half_solved = spm[player]->solve_some(*ls) > 0;
627 std::unique_ptr<LiftingStrategy2> ls(
lsf_->create2(
game_, *spm[player]));
628 spm[player]->initialize_lifting_strategy(*ls);
629 while (spm[player]->solve_some(*ls) == 0)
636 spm[0]->get_strategy(strategy);
637 spm[1]->get_strategy(strategy);
648 std::shared_ptr<LiftingStrategyFactory> lsf,
int version,
bool alt,
650 : lsf_(lsf), version_(version), alt_(alt), stats_(stats)
676 const verti *vertex_map,
verti vertex_map_size )
678 spm_(new
verti[(
std::size_t)len_*game.graph().V()]())
691 const int l =
len(v);
693 for (
int n = l - 1; n >= 0; --n)
695 dst[n] = src[n] + carry;
696 carry = (dst[n] >=
M_[n]);
699 while (k < l) dst[k++] = 0;
std::size_t verti
type used to number vertices
void merge_vertex_maps(ForwardIterator begin, ForwardIterator end, const verti *old_map, verti old_map_size)
void merge_strategies(std::vector< verti > &strategy, const std::vector< verti > &substrat, const std::vector< verti > &vertex_map)
static void abort_all()
Abort all abortable processes.
bool aborted()
Returns whether this instance has been aborted.
verti * spm_
array storing the SPM vector data
DenseSPM(const ParityGame &game, ParityGame::Player player, LiftingStatistics *stats=0, const verti *vertex_map=0, verti vertex_map_size=0)
void set_vec_to_top(verti v)
void set_vec(verti v, const verti src[], bool carry)
LiftingStatistics(const ParityGame &game, long long max_lifts=-1)
std::vector< std::pair< long long, long long > > vertex_stats_
long long lifts_attempted_
long long lifts_succeeded_
void record_lift(verti v, bool success)
virtual void push(verti vertex)=0
virtual void bump(verti vertex)=0
virtual void lifted(verti vertex)=0
const ParityGame & game() const
const ParityGame & game_
Game being solved.
priority_t priority(verti v) const
verti cardinality(int p) const
void make_subgame(const ParityGame &game, ForwardIterator vertices_begin, ForwardIterator vertices_end, bool proper, StaticGraph::EdgeDirection edge_dir=StaticGraph::EDGE_NONE)
Player player(verti v) const
void compress_priorities(const verti cardinality[]=0, bool preserve_parity=true)
const StaticGraph & graph() const
std::vector< verti > Strategy
ParityGame::Strategy solve_alternate()
ParityGame::Strategy solve_normal()
SmallProgressMeasuresSolver2(const ParityGame &game, std::shared_ptr< LiftingStrategyFactory > lsf, bool alternate=false, LiftingStatistics *stats=0, const verti *vmap=0, verti vmap_size=0)
SmallProgressMeasuresSolverFactory(std::shared_ptr< LiftingStrategyFactory > lsf, int version=1, bool alt=false, LiftingStatistics *stats=0)
ParityGameSolver * create(const ParityGame &game, const verti *vmap, verti vmap_size)
LiftingStatistics * stats_
std::shared_ptr< LiftingStrategyFactory > lsf_
bool alternate_
whether to use the alternate algorithm
const verti vmap_size_
size of vertex map
virtual ParityGame::Strategy solve_normal()
std::shared_ptr< LiftingStrategyFactory > lsf_
factory used to create lifting strategy
virtual ParityGame::Strategy solve_alternate()
ParityGame::Strategy solve()
LiftingStatistics * stats_
object to record lifting statistics
const verti * vmap_
current vertex map
static void preprocess_game(ParityGame &game)
SmallProgressMeasuresSolver(const ParityGame &game, std::shared_ptr< LiftingStrategyFactory > lsf, bool alternate=false, LiftingStatistics *stats=0, const verti *vmap=0, verti vmap_size=0)
void debug_print_vertex(int v) const
long long solve_some(LiftingStrategy &ls, long long attempts=work_size)
const verti * vmap_
active vertex map (if any)
LiftingStatistics * stats_
statistics object to record lifts
SmallProgressMeasures(const ParityGame &game, ParityGame::Player player, LiftingStatistics *stats=0, const verti *vmap=0, verti vmap_size=0)
const std::size_t p_
the player to solve for
verti * M_
bounds on the SPM vector components
bool take_max(verti v) const
std::size_t len_
length of SPM vectors
bool is_top(const verti vec[]) const
verti get_min_succ(verti v) const
virtual ~SmallProgressMeasures()
bool less_than(verti v, const verti vec2[], bool carry=0)
bool compare_strict(verti v) const
bool is_dirty(verti v) const
bool lift_to(verti v, const verti vec2[], bool carry=0)
void get_winning_set(ParityGame::Player player, OutputIterator result)
const ParityGame & game() const
bool * dirty_
marks unstable vertices
ParityGame::Player player() const
std::pair< verti, bool > solve_one(LiftingStrategy &ls)
verti vmap_size_
size of vertex map
static const int work_size
Maximum number of lifting attempts in a row before checking timer.
verti get_successor(verti v) const
verti get_strategy(verti v) const
int vector_cmp(const verti vec1[], const verti vec2[], int N) const
void initialize_lifting_strategy(LiftingStrategy2 &ls)
const ParityGame & game_
the game being solved
verti get_ext_succ(verti v, bool take_max) const
virtual void set_vec(verti v, const verti src[], bool carry)=0
ParityGame::Strategy strategy_
current strategy
virtual const verti * vec(verti v) const =0
std::vector< std::pair< verti, verti > > edge_list
const_iterator succ_end(verti v) const
const_iterator succ_begin(verti v) const
bool has_succ(verti v, verti w) const
void remove_edges(edge_list &edges)
const_iterator pred_begin(verti v) const
const_iterator pred_end(verti v) const
edgei outdegree(verti v) const
const verti * const_iterator
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.