Skip to main content

SearchSession

Struct SearchSession 

Source
pub struct SearchSession<'eg, Cfg: EGraphConfig, L: LitVal, const T: bool, const P: bool>
where MSetCanon: VarCanon<Cfg::G, Cfg::C>,
{ /* private fields */ }
Expand description

A search session owns the search-space layer, term pool, best-result table, action cache, and the MCGS statistics overlay. It provides one coherent mark()/restore(token) that snapshots and rolls back all layers together. The e-graph snapshot is borrowed immutably for the session’s lifetime; later e-graph mutations are not observed (§4.1).

Implementations§

Source§

impl<'eg, Cfg: EGraphConfig, L: LitVal, const T: bool, const P: bool> SearchSession<'eg, Cfg, L, T, P>
where MSetCanon: VarCanon<Cfg::G, Cfg::C>,

Source

pub fn new( snap: &'eg AuSnapshot<'eg, Cfg, L, T, P>, cycle_mode: CycleMode, ) -> Self

Create a new session from a snapshot. The snapshot must outlive the session.

Source

pub fn mark(&mut self) -> SearchToken

Snapshot the entire search state. Returns one opaque token; component tokens are not accessible. Layers are marked in dependency order.

Source

pub fn restore(&mut self, token: SearchToken)

Restore the entire search state to a previous mark. Two-phase: every component token is validated against its container and branch genealogy BEFORE any layer is mutated, so a foreign or abandoned token cannot cause a partial restore. Then restores in reverse dependency order (statistics first, then results/terms, then structure).

Source

pub fn run_exact_warm( &mut self, left: Cfg::G, right: Cfg::G, pruning: bool, subsumption: bool, deadline: Option<Duration>, ) -> Result<(TermOf<Cfg>, Completion), AuError>

Exact solve of the root pair on this session’s persistent layers: terms intern into the session pool, and the solve warm-starts from the session’s stored incumbent for the pair. The session’s cycle mode chooses side-context Exact or ordered-pair fixed-point Exact. deadline makes the solve anytime.

Source

pub fn run_uct( &mut self, left: Cfg::G, right: Cfg::G, config: &McgsConfig, ) -> Result<(TermOf<Cfg>, Completion), AuError>

Run MCGS on this session’s persistent layers. Statistics, search space, terms, and results accumulate across calls and roll back with restore(token).

Errors with AuError::CycleModeMismatch if config.cycle_mode differs from the mode this session’s search space was created with: cycle contexts already interned under one mode cannot be reused under the other, and silently ignoring the requested mode would be worse.

Source

pub fn hybrid_stats(&self) -> HybridStats

What McgsConfig::hybrid_exact did, cumulative over every run_uct call on this session.

Source

pub fn pool_quality(&self, term: TermOf<Cfg>) -> (u32, u32)

The lexicographic quality of a term in this session’s pool.

Source

pub fn snapshot(&self) -> &AuSnapshot<'eg, Cfg, L, T, P>

The snapshot this session was built from.

Auto Trait Implementations§

§

impl<'eg, Cfg, L, const T: bool, const P: bool> Freeze for SearchSession<'eg, Cfg, L, T, P>
where &'eg AuSnapshot<'eg, Cfg, L, T, P>: Freeze, SearchSpace<<Cfg as EGraphConfig>::Au>: Freeze, TermPool<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::V, <Cfg as EGraphConfig>::Au>: Freeze, BestResults<<Cfg as EGraphConfig>::Au>: Freeze, ActionCache<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::M>: Freeze, McgsState<<Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::O>: Freeze,

§

impl<'eg, Cfg, L, const T: bool, const P: bool> RefUnwindSafe for SearchSession<'eg, Cfg, L, T, P>
where &'eg AuSnapshot<'eg, Cfg, L, T, P>: RefUnwindSafe, SearchSpace<<Cfg as EGraphConfig>::Au>: RefUnwindSafe, TermPool<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::V, <Cfg as EGraphConfig>::Au>: RefUnwindSafe, BestResults<<Cfg as EGraphConfig>::Au>: RefUnwindSafe, ActionCache<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::M>: RefUnwindSafe, McgsState<<Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::O>: RefUnwindSafe,

§

impl<'eg, Cfg, L, const T: bool, const P: bool> Send for SearchSession<'eg, Cfg, L, T, P>
where &'eg AuSnapshot<'eg, Cfg, L, T, P>: Send, SearchSpace<<Cfg as EGraphConfig>::Au>: Send, TermPool<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::V, <Cfg as EGraphConfig>::Au>: Send, BestResults<<Cfg as EGraphConfig>::Au>: Send, ActionCache<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::M>: Send, McgsState<<Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::O>: Send,

§

impl<'eg, Cfg, L, const T: bool, const P: bool> Sync for SearchSession<'eg, Cfg, L, T, P>
where &'eg AuSnapshot<'eg, Cfg, L, T, P>: Sync, SearchSpace<<Cfg as EGraphConfig>::Au>: Sync, TermPool<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::V, <Cfg as EGraphConfig>::Au>: Sync, BestResults<<Cfg as EGraphConfig>::Au>: Sync, ActionCache<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::M>: Sync, McgsState<<Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::O>: Sync,

§

impl<'eg, Cfg, L, const T: bool, const P: bool> Unpin for SearchSession<'eg, Cfg, L, T, P>
where &'eg AuSnapshot<'eg, Cfg, L, T, P>: Unpin, SearchSpace<<Cfg as EGraphConfig>::Au>: Unpin, TermPool<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::V, <Cfg as EGraphConfig>::Au>: Unpin, BestResults<<Cfg as EGraphConfig>::Au>: Unpin, ActionCache<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::M>: Unpin, McgsState<<Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::O>: Unpin,

§

impl<'eg, Cfg, L, const T: bool, const P: bool> UnsafeUnpin for SearchSession<'eg, Cfg, L, T, P>
where &'eg AuSnapshot<'eg, Cfg, L, T, P>: UnsafeUnpin, SearchSpace<<Cfg as EGraphConfig>::Au>: UnsafeUnpin, TermPool<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::V, <Cfg as EGraphConfig>::Au>: UnsafeUnpin, BestResults<<Cfg as EGraphConfig>::Au>: UnsafeUnpin, ActionCache<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::M>: UnsafeUnpin, McgsState<<Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::O>: UnsafeUnpin,

§

impl<'eg, Cfg, L, const T: bool, const P: bool> UnwindSafe for SearchSession<'eg, Cfg, L, T, P>
where &'eg AuSnapshot<'eg, Cfg, L, T, P>: UnwindSafe, SearchSpace<<Cfg as EGraphConfig>::Au>: UnwindSafe, TermPool<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::V, <Cfg as EGraphConfig>::Au>: UnwindSafe, BestResults<<Cfg as EGraphConfig>::Au>: UnwindSafe, ActionCache<<Cfg as EGraphConfig>::O, <Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::M>: UnwindSafe, McgsState<<Cfg as EGraphConfig>::Au, <Cfg as EGraphConfig>::O>: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.