pub struct DeGrootModel {
pub trust: Vec<Vec<f64>>,
}Expand description
DeGroot consensus model: linear opinion pooling on a network.
Each agent i updates: o_i(t+1) = Σ_j T_{ij} o_j(t) where T is a row-stochastic trust matrix.
Fields§
§trust: Vec<Vec<f64>>Row-stochastic trust matrix T (n×n stored row-major).
Implementations§
Source§impl DeGrootModel
impl DeGrootModel
Sourcepub fn new(trust: Vec<Vec<f64>>) -> Self
pub fn new(trust: Vec<Vec<f64>>) -> Self
Creates a DeGroot model from a trust matrix.
Rows must sum to 1 (caller’s responsibility).
Sourcepub fn from_graph(graph: &NetworkGraph) -> Self
pub fn from_graph(graph: &NetworkGraph) -> Self
Builds a uniform averaging DeGroot model from a graph.
Sourcepub fn run(&self, opinions: &[f64], steps: usize) -> Vec<f64>
pub fn run(&self, opinions: &[f64], steps: usize) -> Vec<f64>
Runs steps iterations, returns final opinions.
Sourcepub fn has_consensus(&self, opinions: &[f64], tol: f64) -> bool
pub fn has_consensus(&self, opinions: &[f64], tol: f64) -> bool
Checks if opinions have converged to consensus (max spread < tol).
Auto Trait Implementations§
impl Freeze for DeGrootModel
impl RefUnwindSafe for DeGrootModel
impl Send for DeGrootModel
impl Sync for DeGrootModel
impl Unpin for DeGrootModel
impl UnsafeUnpin for DeGrootModel
impl UnwindSafe for DeGrootModel
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
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.