pub struct OpinionDynamics {
pub epsilon: f64,
pub mu: f64,
}Expand description
Deffuant-Weisbuch bounded confidence opinion dynamics.
Agents update opinions toward each other only when |o_i - o_j| < ε. Update: o_i += μ(o_j - o_i), o_j += μ(o_i - o_j).
Fields§
§epsilon: f64Confidence bound ε: agents interact only when |o_i - o_j| < epsilon.
mu: f64Convergence parameter μ ∈ (0, 0.5].
Implementations§
Source§impl OpinionDynamics
impl OpinionDynamics
Sourcepub fn run(&self, opinions: &mut Vec<f64>, steps: usize, seed: u64)
pub fn run(&self, opinions: &mut Vec<f64>, steps: usize, seed: u64)
Runs steps of the Deffuant model on opinions (modified in place).
At each step a random pair is chosen; if they are within ε they converge.
Sourcepub fn count_clusters(&self, opinions: &[f64]) -> usize
pub fn count_clusters(&self, opinions: &[f64]) -> usize
Returns the number of opinion clusters (groups within ε/2 of each other).
Auto Trait Implementations§
impl Freeze for OpinionDynamics
impl RefUnwindSafe for OpinionDynamics
impl Send for OpinionDynamics
impl Sync for OpinionDynamics
impl Unpin for OpinionDynamics
impl UnsafeUnpin for OpinionDynamics
impl UnwindSafe for OpinionDynamics
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.