PBeFS
Parallel Best-First Search
Loading...
Searching...
No Matches
AdditivePDB< W, H, Enc > Class Template Reference

the additive heuristic of disjoint pattern tables More...

#include <PBeFS/astar/PatternDatabase.h>

Public Types

using Table = PatternTable< W , H , Enc >
 a table
using Pattern = TilePattern< W , H >
 a pattern
using board_type = typename Pattern::board_type
 a board

Public Member Functions

 AdditivePDB (std::vector< Table > tables, bool reflect=true)
 constructor, taking the tables, all with the same goal
 AdditivePDB (const Partition &partition, const board_type &goal=Pattern::korf_goal(), const PDBOptions &o={})
 constructor, building the tables of a partition for the goal
int heuristic (const std::uint8_t *q) const noexcept
 the heuristic of the state whose tile t is in the cell q[ t ]
int sum (const std::uint8_t *q) const noexcept
 the sum of the values of the tables for the cells q
int exact (const std::uint8_t *q) const
 the heuristic of the cells q, from the residues alone [see PatternTable::exact()]
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
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
const board_type & goal (void) const noexcept
 the goal board
bool reflected (void) const noexcept
 true if the heuristic also looks up the reflection
const std::vector< Table > & tables (void) const noexcept
 the tables
std::size_t bytes (void) const noexcept
 the bytes of the entries of all the tables

Static Public Member Functions

template<class Executor>
static 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

Static Public Attributes

static constexpr int cells = W * H
 the cells

Detailed Description

template<int W, int H, class Enc = NibbleEntries>
class PBeFS_di_unipi_it::AdditivePDB< W, H, Enc >

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].

Member Typedef Documentation

◆ board_type

template<int W, int H, class Enc = NibbleEntries>
using board_type = typename Pattern::board_type

a board

◆ Pattern

template<int W, int H, class Enc = NibbleEntries>
using Pattern = TilePattern< W , H >

a pattern

◆ Table

template<int W, int H, class Enc = NibbleEntries>
using Table = PatternTable< W , H , Enc >

a table

Constructor & Destructor Documentation

◆ AdditivePDB() [1/2]

template<int W, int H, class Enc = NibbleEntries>
AdditivePDB ( std::vector< Table > tables,
bool reflect = true )
inlineexplicit

constructor, taking the tables, all with the same goal

◆ AdditivePDB() [2/2]

template<int W, int H, class Enc = NibbleEntries>
AdditivePDB ( const Partition & partition,
const board_type & goal = Pattern::korf_goal(),
const PDBOptions & o = {} )
inline

constructor, building the tables of a partition for the goal

Builds (or takes from the cache directory of o) the table of each pattern of partition, each one with all the workers of o, on the C++ threads; make() does the same on another runtime.

Member Function Documentation

◆ bytes()

template<int W, int H, class Enc = NibbleEntries>
std::size_t bytes ( void ) const
inlinenodiscardnoexcept

the bytes of the entries of all the tables

◆ delta()

template<int W, int H, class Enc = NibbleEntries>
int delta ( const std::uint8_t * q,
int t,
int c ) const
inlinenodiscardnoexcept

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

◆ exact()

template<int W, int H, class Enc = NibbleEntries>
int exact ( const std::uint8_t * q) const
inlinenodiscard

the heuristic of the cells q, from the residues alone [see PatternTable::exact()]

◆ goal()

template<int W, int H, class Enc = NibbleEntries>
const board_type & goal ( void ) const
inlinenodiscardnoexcept

the goal board

◆ heuristic()

template<int W, int H, class Enc = NibbleEntries>
int heuristic ( const std::uint8_t * q) const
inlinenodiscardnoexcept

the heuristic of the state whose tile t is in the cell q[ t ]

◆ make()

template<int W, int H, class Enc = NibbleEntries>
template<class Executor>
AdditivePDB make ( const Partition & partition,
const board_type & goal = Pattern::korf_goal(),
const PDBOptions & o = {} )
inlinestaticnodiscard

the heuristic of a partition, its tables built on Executor

◆ reflected()

template<int W, int H, class Enc = NibbleEntries>
bool reflected ( void ) const
inlinenodiscardnoexcept

true if the heuristic also looks up the reflection

◆ reflection()

template<int W, int H, class Enc = NibbleEntries>
void reflection ( const std::uint8_t * q,
std::uint8_t * r ) const
inlinenoexcept

writes in r the cells of the reflection of the state of cells q

◆ sum()

template<int W, int H, class Enc = NibbleEntries>
int sum ( const std::uint8_t * q) const
inlinenodiscardnoexcept

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.

◆ tables()

template<int W, int H, class Enc = NibbleEntries>
const std::vector< Table > & tables ( void ) const
inlinenodiscardnoexcept

the tables

Member Data Documentation

◆ cells

template<int W, int H, class Enc = NibbleEntries>
int cells = W * H
staticconstexpr

the cells


The documentation for this class was generated from the following file: