Skip to content

Latest commit

 

History

History
118 lines (84 loc) · 4.68 KB

WHK.rst

File metadata and controls

118 lines (84 loc) · 4.68 KB

Weighted Hegselmann-Krause

The Weighted Hegselmann-Krause was introduced by Milli et al. in 20211.

This model is a variation of the well-known Hegselmann-Krause (HK). During each interaction a random agenti is selected and the set Γϵ of its neighbors whose opinions differ at most ϵ (di, j = |xi(t) − xj(t)| ≤ ϵ) is identified. Moreover, to account for the heterogeneity of interaction frequency among agent pairs, WHK leverages edge weights, thus capturing the effect of different social bonds' strength/trust as it happens in reality. To such extent, each edge (i, j) ∈ E, carries a value wi, j ∈ [0, 1]. The update rule then becomes:

$$\begin{aligned} x_i(t+1)= \left\{ \begin{array}{ll} x_i(t) + \frac{\sum_{j \in \Gamma_{\epsilon}} x_j(t)w_{ij}}{\#\Gamma_{\epsilon}} (1-x_i(t)) \quad \quad \text{\quad if x_i(t) \geq 0}\\\ x_i(t) + \frac{\sum_{j \in \Gamma_{\epsilon}} x_j(t)w_{ij}}{\#\Gamma_{\epsilon}} (1+x_i(t)) \quad \text{if x_i(t) < 0 } \end{array} \right. \end{aligned}$$

The idea behind the WHK formulation is that the opinion of agent i at time t + 1, will be given by the combined effect of his previous belief and the average opinion weighed by its, selected, ϵ-neighbor, where wi, j accounts for i's perceived influence/trust of j.

Statuses

Node statuses are continuous values in [-1,1].

Parameters

Name Type Value Type Default Mandatory Description
epsilon Model float in [0, 1]

---

True Bounded confidence threshold
perc_stubborness Model float in [0, 1]

0

False Percentage of stubborn agent
similarity Model int in {0, 1}

0

False The method use the feature of the nodes ot not
option_for_stubbornness Model int in {-1,0, 1}

0

False Define distribution of stubborns
weight Edge float in [0, 1]

0.1

False Edge weight
stubborn Node int in {0, 1}

0

False The agent is stubborn or not
vector Node Vector of float in [0, 1]

[]

False Vector represents the character of the node

Methods

The following class methods are made available to configure, describe and execute the simulation:

Configure

ndlib.models.opinions.WHKModel.WHKModel

ndlib.models.opinions.WHKModel.WHKModel.__init__(graph)

ndlib.models.opinions.WHKModel.WHKModel.set_initial_status(self, configuration)

ndlib.models.opinions.WHKModel.WHKModel.reset(self)

Describe

ndlib.models.opinions.WHKModel.WHKModel.get_info(self)

ndlib.models.opinions.WHKModel.WHKModel.get_status_map(self)

Execute Simulation

ndlib.models.opinions.WHKModel.WHKModel.iteration(self)

ndlib.models.opinions.WHKModel.WHKModel.iteration_bunch(self, bunch_size)

Example

In the code below is shown an example of instantiation and execution of an WHK model simulation on a random graph: we an epsilon value of 0.32 and a weight equal 0.2 to all the edges.

import networkx as nx
import ndlib.models.ModelConfig as mc
import ndlib.models.opinions as opn

# Network topology
g = nx.erdos_renyi_graph(1000, 0.1)

# Model selection
model = opn.WHKModel(g)

# Model Configuration
config = mc.Configuration()
config.add_model_parameter("epsilon", 0.32)

# Setting the edge parameters
weight = 0.2
if isinstance(g, nx.Graph):
    edges = g.edges
else:
    edges = [(g.vs[e.tuple[0]]['name'], g.vs[e.tuple[1]]['name']) for e in g.es]

for e in edges:
    config.add_edge_configuration("weight", e, weight)


model.set_initial_status(config)

# Simulation execution
iterations = model.iteration_bunch(20)

    1. Milli and G. Rossetti. “Opinion Dynamic Modeling of News Perception”.