pub struct PreparedExpressions { /* private fields */ }Expand description
A shareable arena snapshot and bounded, reuse-admitted extraction caches. Each cache has 16 independent shards, each retaining at most 16 expressions and 1,024 coefficient entries, evicting in insertion order. Before cache initialization, first encounters return owned terms without locking or allocating cache storage. Only repeated roots are admitted. A small direct-mapped history recognizes reuse across interleaved roots, and collisions may delay admission. Once initialized, cached entries are always checked independently of admission history. Larger decompositions are returned uncached.
Implementations§
Source§impl PreparedExpressions
impl PreparedExpressions
pub fn new(arena: ExprArena) -> Self
pub fn arena(&self) -> &ExprArena
Sourcepub fn linear(&self, expr: ExprId) -> Option<AffineTerms<'_>>
pub fn linear(&self, expr: ExprId) -> Option<AffineTerms<'_>>
Direct affine nodes retain their zero-copy path. Reused compound roots may be cached, including failed extractions, within this snapshot’s budget.
§Panics
Panics for an expression outside this arena or a poisoned cache.
Sourcepub fn quadratic(&self, expr: ExprId) -> Option<Extracted<QuadraticTerms>>
pub fn quadratic(&self, expr: ExprId) -> Option<Extracted<QuadraticTerms>>
Extract a quadratic polynomial, sharing terms only after observed reuse.
§Panics
Panics for an expression outside this arena or a poisoned cache.
Sourcepub fn detected_soc(
&self,
variables: &[Variable],
row: &Constraint,
) -> Option<SocForm>
pub fn detected_soc( &self, variables: &[Variable], row: &Constraint, ) -> Option<SocForm>
Detect an optional cone representation using cached polynomial terms.
Sourcepub fn explicit_soc(&self, soc: &SocConstraint) -> Result<SocForm, SolverError>
pub fn explicit_soc(&self, soc: &SocConstraint) -> Result<SocForm, SolverError>
Extract an explicit cone in one streaming pass over its affine members.
§Errors
Returns a backend error for invalid affine cone members.
Methods from Deref<Target = ExprArena>§
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get(&self, id: ExprId) -> &ExprNode
pub fn nodes(&self) -> &[ExprNode]
pub fn num_params(&self) -> usize
Sourcepub fn param_value(&self, p: ParamId) -> f64
pub fn param_value(&self, p: ParamId) -> f64
Current value bound to parameter p.
§Panics
Panics if p was not allocated by Self::new_param on this arena.
Sourcepub fn try_param_value(&self, p: ParamId) -> Option<f64>
pub fn try_param_value(&self, p: ParamId) -> Option<f64>
Look up the value of p, returning None if p is out of range.
Trait Implementations§
Source§impl Debug for PreparedExpressions
impl Debug for PreparedExpressions
Auto Trait Implementations§
impl !Freeze for PreparedExpressions
impl RefUnwindSafe for PreparedExpressions
impl Send for PreparedExpressions
impl Sync for PreparedExpressions
impl Unpin for PreparedExpressions
impl UnsafeUnpin for PreparedExpressions
impl UnwindSafe for PreparedExpressions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more