ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
PackedArray.h File Reference

Arrays of small unsigned integers packed in words, beyond the book: More...

#include "ADS/Contract.h"
#include "ADS/external/MappedFile.h"
#include "ADS/parallel/Executor.h"
#include <algorithm>
#include <array>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <span>
#include <string_view>
#include <vector>
#include "ADS/succinct/impl/PackedArray.tpp"

Go to the source code of this file.

Classes

class  ADS::PackedArray< B, Saturate >
 \( n \) unsigned fields of \( B \) bits, \( 64 / B \) to a word, the values above \( 2^B - 1 \) clamped to it if Saturate More...
class  ADS::TritArray
 \( n \) values in \( \{ 0 , 1 , 2 \} \), five to a byte in base 3 More...

Namespaces

namespace  ADS

Detailed description

Arrays of small unsigned integers packed in words, beyond the book:

  • PackedArray< B >, \( n \) fields of \( B \) bits, \( B \in \{ 1 , 2 , 4 , 8 , 16 , 32 \} \), \( 64 / B \) to a word of 64 bits, so that a field never crosses two words and get( i ) is a shift and a mask of the word \( \lfloor i B / 64 \rfloor \); with Saturate the values above \( 2^B - 1 \) are stored as \( 2^B - 1 \) (and counted by clamped()) instead of breaking the contract, which is what a table of lower bounds wants, a value cut down being still a lower bound;
  • TritArray, \( n \) values in \( \{ 0 , 1 , 2 \} \), five to a byte as the digits of \( \sum_{j < 5} t_j 3^j < 3^5 = 243 \), i.e., \( 8 / 5 = 1.6 \) bits per value against the 2 of PackedArray< 2 > and \( 0.015 \) bits above the entropy \( \log_2 3 \); get( i ) reads the digit from a table of the 243 bytes, and set( i , v ) adds \( ( v - t ) 3^j \) to the byte.

Both are the tables of the searches in large spaces of states, e.g., the pattern databases of the heuristic search, whose entries are distances of a few bits (saturated at a cap) or their residues modulo 3 (Breyer and Korf), and which are filled by a scan of all the states; the constructors on an executor [see Executor.h] fill the fields by blocks of whole words (of whole bytes for TritArray), each block on one thread, so that no two threads write the same word and no atomic is needed. The widths that do not divide 64 are in BitVector [see get( i , len ) and put( i , v , len ) in BitVector.h], whose fields may cross two words (see Arrays of packed fields).

The contracts [see Contract.h]: the places are below \( n \), the values below \( 2^B \) unless Saturate (below 3 for TritArray); the invariant is that the bits past the last field are 0, and that each byte of a TritArray is below 243. The operations are defined in PackedArray.tpp.

See also
A. Felner, R. E. Korf, S. Hanan, Additive pattern database heuristics, Journal of Artificial Intelligence Research 22, 279-318, 2004, doi:10.1613/jair.1480
T. M. Breyer, R. E. Korf, 1.6-bit pattern databases, Proceedings of the 24th AAAI Conference on Artificial Intelligence, 39-44, 2010, doi:10.1609/aaai.v24i1.7558
S. Gog, T. Beller, A. Moffat, M. Petri, From theory to practice: plug and play with succinct data structures, Experimental Algorithms (SEA 2014), Lecture Notes in Computer Science 8504, 326-337, 2014, doi:10.1007/978-3-319-07959-2_28
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa