PBeFS
Parallel Best-First Search
Loading...
Searching...
No Matches
VacuumWorld Class Reference

the vacuum world on a row of at most 32 cells More...

#include <PBeFS/astar/VacuumWorld.h>

Public Types

using state_type = std::uint64_t
 the packed state
using cost_type = int
 the cost type

Public Member Functions

 VacuumWorld (int n, int start, std::uint32_t dirty)
 constructor of the row of n cells, with the robot in the cell start and the dirty cells given by the bits of dirty
std::uint64_t initial_state (void) const noexcept
bool is_goal (std::uint64_t s) const noexcept
std::uint64_t hash (std::uint64_t s) const noexcept
int heuristic (std::uint64_t s) const noexcept
template<class F>
void for_each_successor (std::uint64_t s, int h, F &&f) const
 calls f( t , 1 , h( t ) ) for Suck, Left and Right, if possible
std::size_t num_features (void) const noexcept
 the number of features: the dirty cells and the cells of the robot
template<class F>
void for_each_feature (std::uint64_t s, F &&f) const
 calls f( i ) for each dirty cell i and f( n + r ) for the robot in r
std::size_t num_abstract_features (void) const noexcept
 the number of abstract features: the dirty cells and the robot
std::size_t abstract_feature (std::size_t i) const noexcept
 the abstract feature of a feature: the dirty cell, or n for the robot
std::uint64_t abstract_state (std::uint64_t s) const noexcept
 the abstract state of AHDA*: the dirty cells
std::size_t num_nblocks (void) const noexcept
 the number of nblocks: the cells
std::size_t nblock (std::uint64_t s) const noexcept
 the nblock of PBNF: the cell of the robot
template<class F>
void for_each_nblock_successor (std::size_t b, F &&f) const
 calls f( b' ) for each cell b' next to the cell b
int pairwise_heuristic (std::uint64_t s, std::uint64_t t) const noexcept
 the heuristic of PA*SE: the cells dirty in s and clean in t
std::uint64_t perfect_hash (std::uint64_t s) const noexcept
 the perfect hash: the packed state
int size (void) const noexcept
 the number of cells

Static Public Member Functions

static int robot (std::uint64_t s) noexcept
 the cell of the robot in the state s
static std::uint32_t dirt (std::uint64_t s) noexcept
 the dirty cells in the state s

Detailed Description

the vacuum world on a row of at most 32 cells

The robot moves Left or Right, or Sucks the dirt of its cell, each action costing 1, and the goal is a clean row; the heuristic, the number of the dirty cells, is consistent. A state packs the dirty cells in the bits \( 0 , \ldots , 31 \) and the cell of the robot in the bits \( 32 , \ldots , 37 \), and the word is also its perfect hash.

The features of Zobrist hashing are the dirt of the cell \( i \), for \( i < n \), and the robot in the cell \( r \), numbered \( n + r \). The abstraction keeps the dirt and forgets the robot: the abstract features of Abstract Zobrist hashing are the dirty cells (the \( n \) features of the robot being one abstract feature, which every state has), and the abstract state of AHDA* is the set of the dirty cells, so that a move keeps the owner and only a Suck changes it. The nblocks of PBNF are the cells of the robot, the neighbours of a cell being its abstract successors, and the heuristic of PA*SE between two states is the number of the cells dirty in the first and clean in the second.

Member Typedef Documentation

◆ cost_type

using cost_type = int

the cost type

◆ state_type

using state_type = std::uint64_t

the packed state

Constructor & Destructor Documentation

◆ VacuumWorld()

VacuumWorld ( int n,
int start,
std::uint32_t dirty )
inline

constructor of the row of n cells, with the robot in the cell start and the dirty cells given by the bits of dirty

Member Function Documentation

◆ abstract_feature()

std::size_t abstract_feature ( std::size_t i) const
inlinenodiscardnoexcept

the abstract feature of a feature: the dirty cell, or n for the robot

◆ abstract_state()

std::uint64_t abstract_state ( std::uint64_t s) const
inlinenodiscardnoexcept

the abstract state of AHDA*: the dirty cells

◆ dirt()

std::uint32_t dirt ( std::uint64_t s)
inlinestaticnodiscardnoexcept

the dirty cells in the state s

◆ for_each_feature()

template<class F>
void for_each_feature ( std::uint64_t s,
F && f ) const
inline

calls f( i ) for each dirty cell i and f( n + r ) for the robot in r

◆ for_each_nblock_successor()

template<class F>
void for_each_nblock_successor ( std::size_t b,
F && f ) const
inline

calls f( b' ) for each cell b' next to the cell b

◆ for_each_successor()

template<class F>
void for_each_successor ( std::uint64_t s,
int h,
F && f ) const
inline

calls f( t , 1 , h( t ) ) for Suck, Left and Right, if possible

◆ hash()

std::uint64_t hash ( std::uint64_t s) const
inlinenodiscardnoexcept

◆ heuristic()

int heuristic ( std::uint64_t s) const
inlinenodiscardnoexcept

◆ initial_state()

std::uint64_t initial_state ( void ) const
inlinenodiscardnoexcept

◆ is_goal()

bool is_goal ( std::uint64_t s) const
inlinenodiscardnoexcept

◆ nblock()

std::size_t nblock ( std::uint64_t s) const
inlinenodiscardnoexcept

the nblock of PBNF: the cell of the robot

◆ num_abstract_features()

std::size_t num_abstract_features ( void ) const
inlinenodiscardnoexcept

the number of abstract features: the dirty cells and the robot

◆ num_features()

std::size_t num_features ( void ) const
inlinenodiscardnoexcept

the number of features: the dirty cells and the cells of the robot

◆ num_nblocks()

std::size_t num_nblocks ( void ) const
inlinenodiscardnoexcept

the number of nblocks: the cells

◆ pairwise_heuristic()

int pairwise_heuristic ( std::uint64_t s,
std::uint64_t t ) const
inlinenodiscardnoexcept

the heuristic of PA*SE: the cells dirty in s and clean in t

◆ perfect_hash()

std::uint64_t perfect_hash ( std::uint64_t s) const
inlinenodiscardnoexcept

the perfect hash: the packed state

◆ robot()

int robot ( std::uint64_t s)
inlinestaticnodiscardnoexcept

the cell of the robot in the state s

◆ size()

int size ( void ) const
inlinenodiscardnoexcept

the number of cells


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