Skip to main content

InferenceMethod

Enum InferenceMethod 

Source
pub enum InferenceMethod {
Show 14 variants DirectLookup, MajorityVote, CitationLink, AnalogyInference, PatternSummarize, ArchitecturalChain, DominanceAnalysis, EntityCount, IntervalCalc, FeedbackConsolidation, QualitativeInference, ProvenanceChain, MultiSourceConsensus, ConflictReconciliation,
}
Expand description

One of the 14 registered inference methods. Every Inferential memory’s method field resolves to a symbol whose canonical name maps to one of these variants.

Variants§

§

DirectLookup

Pass-through from a single parent. output.conf = parent.conf.

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let out = InferenceMethod::DirectLookup
    .compute(&[Confidence::try_from_f32(0.73).unwrap()])
    .unwrap();
assert!((out.as_f32() - 0.73).abs() < 0.001);
§

MajorityVote

Majority vote across an odd number of parents (N ≥ 3). Per the spec v1 convention (librarian-pipeline.md § 5.1) the write surface carries only voters-in-favor in derived_from, so votes_for == N and the formula collapses to min(parents.conf).

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let p = |f| Confidence::try_from_f32(f).unwrap();
let out = InferenceMethod::MajorityVote.compute(&[p(0.9), p(0.6), p(0.7)]).unwrap();
assert!((out.as_f32() - 0.6).abs() < 0.001);

Citation-linked pair of parents. output.conf = min(parents.conf) * 0.9.

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let p = |f| Confidence::try_from_f32(f).unwrap();
let out = InferenceMethod::CitationLink.compute(&[p(1.0), p(1.0)]).unwrap();
assert!((out.as_f32() - 0.9).abs() < 0.001);
§

AnalogyInference

Analogical mapping from source to target. output.conf = product(parents.conf) * 0.7.

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let p = |f| Confidence::try_from_f32(f).unwrap();
let out = InferenceMethod::AnalogyInference.compute(&[p(1.0), p(1.0)]).unwrap();
assert!((out.as_f32() - 0.7).abs() < 0.001);
§

PatternSummarize

Geometric-mean summarization over N ≥ 2 parents. output.conf = geomean(parents.conf) * 0.8.

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let p = |f| Confidence::try_from_f32(f).unwrap();
// geomean(0.5, 0.5) = 0.5; * 0.8 = 0.4.
let out = InferenceMethod::PatternSummarize.compute(&[p(0.5), p(0.5)]).unwrap();
assert!((out.as_f32() - 0.4).abs() < 0.001);
§

ArchitecturalChain

Chained architectural derivation. output.conf = product(parents.conf).

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let p = |f| Confidence::try_from_f32(f).unwrap();
// 0.5 * 0.5 * 0.5 = 0.125.
let out = InferenceMethod::ArchitecturalChain
    .compute(&[p(0.5), p(0.5), p(0.5)]).unwrap();
assert!((out.as_f32() - 0.125).abs() < 0.001);
§

DominanceAnalysis

Dominance / ranking analysis. output.conf = min(parents.conf) * 0.6.

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let p = |f| Confidence::try_from_f32(f).unwrap();
// min(0.9, 0.5) * 0.6 = 0.3.
let out = InferenceMethod::DominanceAnalysis.compute(&[p(0.9), p(0.5)]).unwrap();
assert!((out.as_f32() - 0.3).abs() < 0.001);
§

EntityCount

Cardinality / count over N ≥ 1 parents. output.conf = min(parents.conf) * 0.8.

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let p = |f| Confidence::try_from_f32(f).unwrap();
let out = InferenceMethod::EntityCount.compute(&[p(0.7)]).unwrap();
assert!((out.as_f32() - 0.56).abs() < 0.001); // 0.7 * 0.8.
§

IntervalCalc

Interval calculation between two endpoint parents. output.conf = min(parents.conf) * 0.9.

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let p = |f| Confidence::try_from_f32(f).unwrap();
let out = InferenceMethod::IntervalCalc.compute(&[p(0.8), p(0.6)]).unwrap();
assert!((out.as_f32() - 0.54).abs() < 0.001); // min=0.6; *0.9.
§

FeedbackConsolidation

Feedback consolidation over N ≥ 1 parents. output.conf = min(parents.conf) * 0.85.

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let p = |f| Confidence::try_from_f32(f).unwrap();
let out = InferenceMethod::FeedbackConsolidation.compute(&[p(0.6)]).unwrap();
assert!((out.as_f32() - 0.51).abs() < 0.001); // 0.6 * 0.85.
§

QualitativeInference

Qualitative / narrative inference. output.conf = min(parents.conf) * 0.5.

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let p = |f| Confidence::try_from_f32(f).unwrap();
let out = InferenceMethod::QualitativeInference.compute(&[p(0.8)]).unwrap();
assert!((out.as_f32() - 0.4).abs() < 0.001);
§

ProvenanceChain

Provenance chain through N ≥ 2 parents. output.conf = product(parents.conf).

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let p = |f| Confidence::try_from_f32(f).unwrap();
let out = InferenceMethod::ProvenanceChain.compute(&[p(0.9), p(0.8)]).unwrap();
assert!((out.as_f32() - 0.72).abs() < 0.001);
§

MultiSourceConsensus

Noisy-OR consensus across independent parents. output.conf = 1 - product(1 - parents.conf).

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let p = |f| Confidence::try_from_f32(f).unwrap();
// 1 - (0.5)(0.5) = 0.75.
let out = InferenceMethod::MultiSourceConsensus.compute(&[p(0.5), p(0.5)]).unwrap();
assert!((out.as_f32() - 0.75).abs() < 0.001);
§

ConflictReconciliation

Conflict reconciliation over contested peers. output.conf = max(parents.conf) * 0.8.

use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;
let p = |f| Confidence::try_from_f32(f).unwrap();
// max(0.3, 0.9) * 0.8 = 0.72.
let out = InferenceMethod::ConflictReconciliation.compute(&[p(0.3), p(0.9)]).unwrap();
assert!((out.as_f32() - 0.72).abs() < 0.001);

Implementations§

Source§

impl InferenceMethod

Source

pub fn symbol_name(self) -> &'static str

The canonical symbol name (with leading @) for this method.

Source

pub fn from_symbol_name(name: &str) -> Option<Self>

Resolve a canonical method name (with or without leading @) to a variant, or None if the name is not a registered method.

Source

pub fn parent_count_rule(self) -> ParentCountRule

Parent-count rule expected by this method.

Source

pub fn staleness_rule(self) -> StalenessRule

Staleness predicate per spec § 5.1.

Source

pub fn compute( self, parents: &[Confidence], ) -> Result<Confidence, InferenceMethodError>

Compute the output confidence for this method given parent confidences. See variant docs for each formula.

§Errors
§Example
use mimir_core::inference_methods::InferenceMethod;
use mimir_core::Confidence;

let parents = [Confidence::ONE, Confidence::ONE];
let out = InferenceMethod::CitationLink.compute(&parents).unwrap();
// min(1.0, 1.0) * 0.9 ≈ 0.9; allow ±1 fixed-point step of drift.
let expected = (f32::from(u16::MAX) * 0.9) as u16;
assert!((i32::from(out.as_u16()) - i32::from(expected)).abs() <= 1);

Trait Implementations§

Source§

impl Clone for InferenceMethod

Source§

fn clone(&self) -> InferenceMethod

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for InferenceMethod

Source§

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

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

impl Hash for InferenceMethod

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for InferenceMethod

Source§

fn eq(&self, other: &InferenceMethod) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for InferenceMethod

Source§

impl Eq for InferenceMethod

Source§

impl StructuralPartialEq for InferenceMethod

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> 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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 = 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more