mCRL2
|
#include <SmallProgressMeasures.h>
Public Member Functions | |
SmallProgressMeasures (const ParityGame &game, ParityGame::Player player, LiftingStatistics *stats=0, const verti *vmap=0, verti vmap_size=0) | |
virtual | ~SmallProgressMeasures () |
long long | solve_some (LiftingStrategy &ls, long long attempts=work_size) |
long long | solve_some (LiftingStrategy2 &ls, long long attempts=work_size) |
std::pair< verti, bool > | solve_one (LiftingStrategy &ls) |
verti | solve_one (LiftingStrategy2 &ls) |
verti | get_strategy (verti v) const |
void | get_strategy (ParityGame::Strategy &strat) const |
template<class OutputIterator > | |
void | get_winning_set (ParityGame::Player player, OutputIterator result) |
bool | lift_to_top (verti v) |
bool | lift_to (verti v, const verti vec2[], bool carry=0) |
bool | less_than (verti v, const verti vec2[], bool carry=0) |
void | debug_print () const |
void | debug_print_vertex (int v) const |
bool | verify_solution () |
const ParityGame & | game () const |
ParityGame::Player | player () const |
int | len () const |
const verti * | M () const |
void | set_M (const verti *new_M) |
void | decr_M (int i) |
int | len (verti v) const |
bool | is_top (const verti vec[]) const |
bool | is_top (verti v) const |
virtual const verti * | vec (verti v) const =0 |
virtual void | set_vec (verti v, const verti src[], bool carry)=0 |
virtual void | set_vec_to_top (verti v)=0 |
void | initialize_lifting_strategy (LiftingStrategy2 &ls) |
Static Public Attributes | |
static const int | work_size = 10000 |
Maximum number of lifting attempts in a row before checking timer. | |
Protected Member Functions | |
void | initialize_loops () |
void | set_top (verti v) |
Protected Attributes | |
const ParityGame & | game_ |
the game being solved | |
const std::size_t | p_ |
the player to solve for | |
LiftingStatistics * | stats_ |
statistics object to record lifts | |
const verti * | vmap_ |
active vertex map (if any) | |
verti | vmap_size_ |
size of vertex map | |
std::size_t | len_ |
length of SPM vectors | |
verti * | M_ |
bounds on the SPM vector components | |
ParityGame::Strategy | strategy_ |
current strategy | |
bool * | dirty_ |
marks unstable vertices | |
Private Member Functions | |
SmallProgressMeasures (const SmallProgressMeasures &) | |
SmallProgressMeasures & | operator= (const SmallProgressMeasures &) |
int | vector_cmp (const verti vec1[], const verti vec2[], int N) const |
int | vector_cmp (verti v, verti w, int N) const |
bool | take_max (verti v) const |
bool | compare_strict (verti v) const |
verti | get_ext_succ (verti v, bool take_max) const |
verti | get_ext_succ (verti v) const |
verti | get_min_succ (verti v) const |
verti | get_max_succ (verti v) const |
verti | get_successor (verti v) const |
bool | is_dirty (verti v) const |
Friends | |
class | PredecessorLiftingStrategy |
class | MaxMeasureLiftingStrategy2 |
class | OldMaxMeasureLiftingStrategy |
Implements the core of the Small Progress Measures algorithm, which keeps track of progress measure vectors, and allows lifting at vertices.
Note that besides these vectors, it tracks the current lifting strategy and (optionally) a statistics object. All public methods of this class notify the lifting strategy whenever vectors change (due to one of the solve..() lift..() methods), but only when vertices are lifted through one of the solve..() methods, are lifting attempts recording in the statistics object.
As a result, the lift..() methods can be used to introduce information from external sources into the game, without affecting the statistics for updates that result from local lifting attempts. These methods are thus used in the two-way approach to propagate information from the dual game, and the MPI recursive solver.
Note that this is an abstract base class: subclasses may implement different storage formats for the progress measure vectors.
Definition at line 84 of file SmallProgressMeasures.h.
SmallProgressMeasures::SmallProgressMeasures | ( | const ParityGame & | game, |
ParityGame::Player | player, | ||
LiftingStatistics * | stats = 0 , |
||
const verti * | vmap = 0 , |
||
verti | vmap_size = 0 |
||
) |
Definition at line 37 of file SmallProgressMeasures.cpp.
|
virtual |
Definition at line 110 of file SmallProgressMeasures.cpp.
|
private |
|
inlineprivate |
Returns whether the progress measure for vertex v
must be strictly greater than its successors or not (which is true if its priority has parity different from the current player).
Definition at line 233 of file SmallProgressMeasures.h.
void SmallProgressMeasures::debug_print | ( | ) | const |
For debugging: print current state to stdout
void SmallProgressMeasures::debug_print_vertex | ( | int | v | ) | const |
|
inline |
Decrements the i'th element of M.
Definition at line 170 of file SmallProgressMeasures.h.
|
inline |
Return the parity to be solved.
Definition at line 154 of file SmallProgressMeasures.h.
Returns the minimum or maximum successor for vertex v
depending on whether it is owned by player p_
or not.
Returns the minimum or maximum successor for vertex v
, depending on whether take_max is false or true (respectively).
Definition at line 39 of file SmallProgressMeasures_impl.h.
Returns the maximum successor for vertex v
.
Definition at line 247 of file SmallProgressMeasures.h.
Returns the minimum successor for vertex v
.
Definition at line 244 of file SmallProgressMeasures.h.
void SmallProgressMeasures::get_strategy | ( | ParityGame::Strategy & | strat | ) | const |
Takes an initialized strategy vector and updates it for the current player. The result is valid only after the game is solved.
Definition at line 235 of file SmallProgressMeasures.cpp.
After the game is solved, this returns the strategy at vertex v
for the current player, or NO_VERTEX if the vertex is controlled by his opponent (in that case, any move is winning) or if it is won by his opponent (in that case, all moves are losing).
Definition at line 230 of file SmallProgressMeasures.cpp.
Returns whether the succesor with the extreme progress measure for the given vertex. (Extreme
means minimal for even-controlled vertices, and maximal for odd-controlled vertices.)
Definition at line 252 of file SmallProgressMeasures.h.
void SmallProgressMeasures::get_winning_set | ( | ParityGame::Player | player, |
OutputIterator | result | ||
) |
Returns the winning set for the given player by assigning the vertices in the set to the given output iterator. If the game is not completely solved yet, then this returns a subset of the winning set.
Definition at line 57 of file SmallProgressMeasures_impl.h.
void SmallProgressMeasures::initialize_lifting_strategy | ( | LiftingStrategy2 & | ls | ) |
Recalculates the set of dirty vertices, and pushes them into the given lifting strategy (which is assumed to be freshly allocated).
Definition at line 88 of file SmallProgressMeasures.cpp.
|
protected |
Sets odd-controlled vertices with (only) loops to top. Should be called by derived classes after allocating SPM data.
Definition at line 57 of file SmallProgressMeasures.cpp.
|
inlineprivate |
Returns whether the given vertex is dirty; i.e. its progress measure is less than its successor (or less than or equal to, if its priority is odd).
Definition at line 257 of file SmallProgressMeasures.h.
|
inline |
Return whether the given SPM vector has top value.
Definition at line 177 of file SmallProgressMeasures.h.
|
inline |
Return whether the SPM vector for vertex v
has top value.
Definition at line 180 of file SmallProgressMeasures.h.
|
inline |
Return the length of the SPM vectors (a positive integer).
Definition at line 160 of file SmallProgressMeasures.h.
|
inline |
Return the number of odd priorities less than or equal to the priority of v. This is the length of the SPM vector for v
.
Definition at line 174 of file SmallProgressMeasures.h.
Returns the same result as lift_to() but without changing any progress measure vectors.
Definition at line 247 of file SmallProgressMeasures.cpp.
Sets the given vertex's progress measure to the given value, if this is greater than the current value, and returns whether it changed. val[] must be an array of length len(v). If carry is set, the new value must be strictly greater (or top).
Definition at line 255 of file SmallProgressMeasures.cpp.
|
inline |
Sets the given vertex's progress measure to top, if it isn't already, and returns whether it changed:
Definition at line 151 of file SmallProgressMeasures_impl.h.
|
inline |
Returns the SPM vector space; an array of len() integers.
Definition at line 163 of file SmallProgressMeasures.h.
|
private |
|
inline |
Return the player to solve for.
Definition at line 157 of file SmallProgressMeasures.h.
|
inline |
Changes the SPM vector space. new_M
must be an array of at least len
non-negative integers.
Definition at line 167 of file SmallProgressMeasures.h.
|
inlineprotected |
Set the SPM vector for vertex v
to top value. This can decrease the vector space, but nothing else; e.g, the lifting strategy is not notified of the lift.
Definition at line 158 of file SmallProgressMeasures_impl.h.
Assign the first len(v)
elements of the vector for vertex w
to the vector for v
, or its successor if carry
is set.
Implemented in DenseSPM.
|
pure virtual |
Set the value for vertex v
to top.
Implemented in DenseSPM.
std::pair< verti, bool > SmallProgressMeasures::solve_one | ( | LiftingStrategy & | ls | ) |
Performs one lifting attempt, and returns the index of the vertex and whether lifting succeeded. Returns NO_VERTEX if no more vertices were candidates for lifting.
Definition at line 130 of file SmallProgressMeasures.cpp.
verti SmallProgressMeasures::solve_one | ( | LiftingStrategy2 & | ls | ) |
Definition at line 152 of file SmallProgressMeasures.cpp.
long long SmallProgressMeasures::solve_some | ( | LiftingStrategy & | ls, |
long long | attempts = work_size |
||
) |
Performs some work on the game using the given lifting strategy (which must have been initialized).
max_attempts | Maximum number of lifts attempted. |
Definition at line 116 of file SmallProgressMeasures.cpp.
long long SmallProgressMeasures::solve_some | ( | LiftingStrategy2 & | ls, |
long long | attempts = work_size |
||
) |
Definition at line 123 of file SmallProgressMeasures.cpp.
|
inlineprivate |
Returns whehter vertex v
is lifted to the maximum successor (true) or minimum successor (false), which in turn depends on whether it is controlled by the player p_
we are solving for.
Definition at line 228 of file SmallProgressMeasures.h.
Return the SPM vector for vertex v
. This array contains only the components with odd (for Even) or even (for Odd) indices of the vector (since the reset is fixed at zero).
Implemented in DenseSPM.
|
inlineprivate |
Compares the first N
elements of the given SPM vectors and returns -1, 0 or 1 to indicate that v is smaller than, equal to, or larger than w (respectively).
Definition at line 24 of file SmallProgressMeasures_impl.h.
Compares N
elements of the SPM vectors for the given vertices.
Definition at line 19 of file SmallProgressMeasures_impl.h.
bool SmallProgressMeasures::verify_solution | ( | ) |
For debugging: verify that the current state describes a valid SPM
|
friend |
Definition at line 261 of file SmallProgressMeasures.h.
|
friend |
Definition at line 262 of file SmallProgressMeasures.h.
|
friend |
Definition at line 260 of file SmallProgressMeasures.h.
|
protected |
marks unstable vertices
Definition at line 273 of file SmallProgressMeasures.h.
|
protected |
the game being solved
Definition at line 265 of file SmallProgressMeasures.h.
|
protected |
length of SPM vectors
Definition at line 270 of file SmallProgressMeasures.h.
|
protected |
bounds on the SPM vector components
Definition at line 271 of file SmallProgressMeasures.h.
|
protected |
the player to solve for
Definition at line 266 of file SmallProgressMeasures.h.
|
protected |
statistics object to record lifts
Definition at line 267 of file SmallProgressMeasures.h.
|
protected |
current strategy
Definition at line 272 of file SmallProgressMeasures.h.
|
protected |
active vertex map (if any)
Definition at line 268 of file SmallProgressMeasures.h.
|
protected |
size of vertex map
Definition at line 269 of file SmallProgressMeasures.h.
|
static |
Maximum number of lifting attempts in a row before checking timer.
Definition at line 88 of file SmallProgressMeasures.h.