pub struct NoveltyTable { /* private fields */ }Expand description
Records every feature tuple of size <= k seen so far.
The novelty of a state is the size of the smallest tuple of its features
that has not been seen before. Size-1 and size-2 tuples use dense bitsets
(n and n(n-1)/2 bits); larger sizes fall back to hashing.
Implementations§
Source§impl NoveltyTable
impl NoveltyTable
Sourcepub fn new(num_features: usize, k: usize) -> Self
pub fn new(num_features: usize, k: usize) -> Self
Creates an empty table for features 0..num_features and tuples up to size k.
Memory is num_features bools plus, for k >= 2, a bitset of
num_features * (num_features - 1) / 2 pairs. For k >= 3, every distinct
tuple of size 3 to k seen so far is also kept in a hash set, which grows
with the explored states rather than with num_features.
§Panics
Panics if k is 0.
Sourcepub fn width_bound(&self) -> usize
pub fn width_bound(&self) -> usize
The width bound k this table was created with.
Sourcepub fn evaluate_and_insert(&mut self, features: &[u32]) -> Option<usize>
pub fn evaluate_and_insert(&mut self, features: &[u32]) -> Option<usize>
Returns the novelty of a state with the given features (None if it
exceeds k), and records all of its tuples of size <= k.
Duplicate features are ignored.
§Panics
Panics if a feature is not below the num_features given to
NoveltyTable::new.