AdditivePDB
Declared in astar/PatternDatabase.h; the same class on the site of Doxygen.
-
template<int W, int H, class Enc = NibbleEntries>
class AdditivePDB the additive heuristic of disjoint pattern tables
The tables are those of a partition of (some of) the tiles into disjoint patterns, and the heuristic of a state is the sum of the values of its placements in the tables. With the blank ignored or minimized, a move of the puzzle moves one tile, hence it is a move of the abstraction of at most one pattern, which counts it once; the sum of the abstract distances is thus at most the true one (admissible), and with the blank ignored it changes by at most one along a move (consistent). On a square board whose goal has the blank on the main diagonal, the heuristic is also the maximum with the same sum on the reflection of the state about the diagonal, which is an automorphism of the puzzle fixing the goal [see the file header].
Public Types
-
using Table = PatternTable<W, H, Enc>
a table
-
using Pattern = TilePattern<W, H>
a pattern
Public Functions
-
inline explicit AdditivePDB(std::vector<Table> tables, bool reflect = true)
constructor, taking the tables, all with the same goal
- inline AdditivePDB(
- const Partition &partition,
- const board_type &goal = Pattern::korf_goal(),
- const PDBOptions &o = {}
constructor, building the tables of a partition for the goal
Builds (or takes from the cache directory of
o) the table of each pattern ofpartition, each one with all the workers ofo, on the C++ threads; make() does the same on another runtime.
-
inline int heuristic(const std::uint8_t *q) const noexcept
the heuristic of the state whose tile t is in the cell q[ t ]
-
inline int sum(const std::uint8_t *q) const noexcept
the sum of the values of the tables for the cells q
The sum of the tables only, without the reflection: for the tests and the benchmarks.
-
inline int exact(const std::uint8_t *q) const
the heuristic of the cells q, from the residues alone [see PatternTable::exact()]
-
inline int delta(const std::uint8_t *q, int t, int c) const noexcept
the change of the sum when the tile t moves from the cells q to the cell c, from the residues of the table of t (CHILD-H of the file header); 0 for a tile in no pattern
-
inline void reflection(const std::uint8_t *q, std::uint8_t *r) const noexcept
writes in r the cells of the reflection of the state of cells q
-
inline const board_type &goal(void) const noexcept
the goal board
-
inline bool reflected(void) const noexcept
true if the heuristic also looks up the reflection
-
inline std::size_t bytes(void) const noexcept
the bytes of the entries of all the tables
Public Static Functions
-
template<class Executor>
static inline AdditivePDB make( - const Partition &partition,
- const board_type &goal = Pattern::korf_goal(),
- const PDBOptions &o = {}
the heuristic of a partition, its tables built on Executor
-
using Table = PatternTable<W, H, Enc>