Skip to main content

Ledger

Struct Ledger 

Source
pub struct Ledger<R, N> { /* private fields */ }
Expand description

The threaded state of a run: what was spent on the device, and what was only computed.

Device time is the scarce resource. Context is read-only and cannot accumulate, the log is a record rather than a running total, and the value is the answer rather than the meter, so state is the only channel both writable and threaded, and this is what rides it.

Counts are ℕ on N: NaturalNumber, whose width a program names once with NumberType; widening it buys headroom and moves no threshold. Real quantities are on R. Copy, with no Vec and no String, and a hand-written Default from the two zeros, because the causal monad requires State: Default and a derived one would demand R: Default.

§Three invariants

observe is the only stage that touches shots, experiments and device_time; predict touches predictions and nothing on the device side. fork is the pipeline’s, above core, by cloning. Forked ledgers are compared, never joined under ∇: at a counterfactual fork exactly one branch was factual, and a monoid that summed them would typecheck and be wrong.

Implementations§

Source§

impl<R: RealField, N: NaturalNumber> Ledger<R, N>

Source

pub fn new() -> Self

The empty ledger.

Source

pub fn shots(&self) -> N

Shots taken on the device.

Source

pub fn experiments(&self) -> N

Experiments executed on hardware.

Source

pub fn predictions(&self) -> N

Model evaluations: tracked, never billed.

Source

pub fn device_time(&self) -> R

Accumulated device time.

Source

pub fn cost(&self) -> R

The cost the design objective minimised.

Source

pub fn bits(&self) -> R

The separation achieved so far, in bits.

Source

pub fn draw_down(budget: N, request: N) -> Result<N, QuantumError>
where N: Debug,

The remainder of budget after drawing request from it, in checked ℕ arithmetic.

§Errors

QuantumError::CalculationError naming the shortfall when request exceeds budget: checked_difference returned None, and monus says by how much.

Trait Implementations§

Source§

impl<R: Clone, N: Clone> Clone for Ledger<R, N>

Source§

fn clone(&self) -> Ledger<R, N>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<R: Copy, N: Copy> Copy for Ledger<R, N>

Source§

impl<R: Debug, N: Debug> Debug for Ledger<R, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<R: RealField, N: NaturalNumber> Default for Ledger<R, N>

Source§

fn default() -> Self

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

impl<R: PartialEq, N: PartialEq> PartialEq for Ledger<R, N>

Source§

fn eq(&self, other: &Ledger<R, N>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<R: PartialEq, N: PartialEq> StructuralPartialEq for Ledger<R, N>

Auto Trait Implementations§

§

impl<R, N> Freeze for Ledger<R, N>
where N: Freeze, R: Freeze,

§

impl<R, N> RefUnwindSafe for Ledger<R, N>

§

impl<R, N> Send for Ledger<R, N>
where N: Send, R: Send,

§

impl<R, N> Sync for Ledger<R, N>
where N: Sync, R: Sync,

§

impl<R, N> Unpin for Ledger<R, N>
where N: Unpin, R: Unpin,

§

impl<R, N> UnsafeUnpin for Ledger<R, N>
where N: UnsafeUnpin, R: UnsafeUnpin,

§

impl<R, N> UnwindSafe for Ledger<R, N>
where N: UnwindSafe, R: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<Borrowed> SampleBorrow<Borrowed> for Borrowed

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.