Skip to main content

PenroseMemory

Struct PenroseMemory 

Source
pub struct PenroseMemory { /* private fields */ }
Expand description

Aperiodic memory palace navigated by dead reckoning.

Embeddings are projected to 2D Penrose coordinates using golden-ratio hashing. The Fibonacci word determines tile bits. Recall walks from query toward stored memories via dead reckoning.

Implementations§

Source§

impl PenroseMemory

Source

pub fn new(embedding_dim: usize) -> Self

Create a new PenroseMemory with the given embedding dimension.

Source

pub fn store(&mut self, embedding: &[f64], content: u64) -> u64

Store an embedding with associated content.

Projects the embedding to 2D Penrose coordinates and stores it. Returns the tile_id.

Source

pub fn recall(&self, query: &[f64], max_steps: usize) -> Vec<RecallResult>

Recall memories by dead reckoning from a query embedding.

Projects the query to 2D, then finds the closest stored tiles. Dead reckoning: we walk from the query point toward stored memories, measuring distance and confidence at each step.

max_steps controls how many intermediate waypoints to check along the path to each candidate.

Source

pub fn navigate(&self, tile_id: u64, distance: f64, heading: f64) -> Vec<u64>

Navigate from a tile by distance and heading.

Dead reckoning navigation: start from the given tile, walk the specified distance at the given heading, and find tiles near the destination. Returns tile IDs of tiles found within the arrival radius.

Source

pub fn consolidate(&mut self)

Consolidate (deflate) old memories using golden hierarchy.

Tiles at level 0 that are close together (within φ^1 distance) are merged into a single tile at level 1. The merged content is XOR’d. Returns the number of tiles removed.

Source

pub fn len(&self) -> usize

Number of stored tiles.

Source

pub fn matching_rule_holds(&self, qx: i64, qy: i64) -> bool

Check matching rules at a lattice position. A tile matches if it has at least one neighbor of the opposite type.

Source

pub fn get_tile_bit(&self, qx: i64, qy: i64) -> bool

Get the golden-ratio hash bit for a position.

Source

pub fn get_color(&self, qx: i64, qy: i64) -> u8

Get the 3-coloring for a position.

Source

pub fn is_empty(&self) -> bool

Check if the memory is empty.

Source

pub fn supersede_tile(&mut self, tile_id: u64) -> Option<u64>

Supersede a tile — mark old as Superseded, return its content.

Source

pub fn retract_tile(&mut self, tile_id: u64) -> bool

Retract a tile — mark as Retracted with reason.

Source

pub fn active_tile_ids(&self) -> Vec<u64>

Get only active tile IDs.

Source

pub fn lifecycle_stats(&self) -> (usize, usize, usize)

Count tiles by lifecycle state.

Source

pub fn predict_recall( &self, query: &[f64], clock: &mut LamportClock, ) -> MemoryPrediction

Predict where a memory will be found before walking there. Uses the same projection as recall but without executing the walk.

Source

pub fn confirm_prediction( &self, prediction: &mut MemoryPrediction, actual: &[RecallResult], ) -> bool

Confirm a prediction against actual recall results.

Trait Implementations§

Source§

impl Default for PenroseMemory

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.