Skip to main content

Bisection

Struct Bisection 

Source
pub struct Bisection {
    pub domain_size: u64,
    pub budget: Budget,
    pub lo: u64,
    pub hi: u64,
    pub threshold: u64,
}
Expand description

Bounded monotone-boundary bisection carrier.

Fields§

§domain_size: u64

Size of the ordered domain.

§budget: Budget

Budget that counts admitted probes.

§lo: u64

Inclusive lower interval endpoint.

§hi: u64

Inclusive upper interval endpoint.

§threshold: u64

Monotone boundary retained inside the interval.

Implementations§

Source§

impl Bisection

Source

pub fn new( lo: u64, hi: u64, threshold: u64, domain_size: u64, max_probes: u64, ) -> Bisection

Init (TLA+ Init): a candidate interval straddling the threshold, no probes taken yet.

Source

pub fn converged(&self) -> bool

Whether the interval has been narrowed to a point (TLA+ Converged guard).

Source

pub fn probe(&mut self)

Probe the midpoint and narrow the interval – one atomic step (TLA+ ProbeLeft / ProbeRight). Maintains MonotonicityPreservation, at least halves the interval (the Halving property), and strictly decreases its width (the loop-termination measure).

Source

pub fn bisect(&mut self)

Drive probes to convergence (the TLA+ EventualConvergence under fairness). The decreases hi - lo is the loop-termination witness: the loop halts, and on exit the interval is a point (hi - lo < 2) that still straddles the threshold.

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

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.