pub struct DecisionEngine {
pub quorum: usize,
}Expand description
Weighs ternary options and produces decisions.
Each option is a ternary value. The engine collects votes from agents and produces a final ternary decision.
Fields§
§quorum: usizeMinimum number of votes required for a decision.
Implementations§
Source§impl DecisionEngine
impl DecisionEngine
pub fn new(quorum: usize) -> Self
Sourcepub fn decide(&self, votes: &[Ternary]) -> Option<Ternary>
pub fn decide(&self, votes: &[Ternary]) -> Option<Ternary>
Decide from a list of ternary votes using majority rule. Returns None if quorum isn’t met.
Sourcepub fn decide_weighted(&self, votes: &[(Ternary, f64)]) -> Option<Ternary>
pub fn decide_weighted(&self, votes: &[(Ternary, f64)]) -> Option<Ternary>
Decide using weighted votes. Each vote has a weight.
Sourcepub fn consensus_strength(&self, votes: &[Ternary]) -> f64
pub fn consensus_strength(&self, votes: &[Ternary]) -> f64
Compute consensus strength: ratio of majority votes to total.
Trait Implementations§
Source§impl Clone for DecisionEngine
impl Clone for DecisionEngine
Source§fn clone(&self) -> DecisionEngine
fn clone(&self) -> DecisionEngine
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DecisionEngine
impl RefUnwindSafe for DecisionEngine
impl Send for DecisionEngine
impl Sync for DecisionEngine
impl Unpin for DecisionEngine
impl UnsafeUnpin for DecisionEngine
impl UnwindSafe for DecisionEngine
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
Mutably borrows from an owned value. Read more