Deffuant Model#

The Deffuant Model, also known as the “Mixing of Beliefs among Interacting Agents,” describes how agents update their continuous opinions through random binary encounters. In this model, agents only adjust their opinions if the difference between their opinions is below a specified threshold, known as the Homophily Threshold.

Model Dynamics#

Homophily Threshold:

If the difference in opinions between two interacting agents is less than this threshold, they will update their opinions towards each other. This process leads to opinion convergence or clustering depending on the value of the threshold.

High Thresholds:

When the Homophily Threshold is high, opinions tend to converge towards an average opinion, as agents are more selective about whom they interact with.

Low Thresholds:

When the Homophily Threshold is low, the model results in the formation of several distinct opinion clusters. Agents within the same cluster share similar opinions and are less influenced by agents outside their cluster.

Example:#

>>> from pyseldonlib import Deffuant_Model
>>> # Create the Deffuant Model
>>> deffuant = Deffuant_Model(max_iterations=1000, homophily_threshold=0.2, mu=0.5)
>>> # Run the simulation
>>> deffuant.run("output_dir")
>>> # Access the network
>>> network = deffuant.get_Network()
>>> # Access the opinions of the agents
>>> opinions = deffuant.agents_opinions()

Reference:#

[1]

Guillaume Deffuant, David Neau, Frederic Amblard, and Gérard Weisbuch. Mixing beliefs among interacting agents. Advances in Complex Systems, 03(01n04):87–98, 2000. URL: https://doi.org/10.1142/S0219525900000078, arXiv:https://doi.org/10.1142/S0219525900000078, doi:10.1142/S0219525900000078.


class pyseldonlib.DeffuantModel.Deffuant_Model(max_iterations: int = None, homophily_threshold: float = 0.2, mu: float = 0.5, use_network: bool = False, rng_seed: int | None = None, agent_file: str | None = None, network_file: str | None = None, other_settings: Other_Settings = None)[source]#

Bases: Base_Model

Deffuant Model base class for Simulation.

Parameters:
  • max_iterations (int, default=None) – The maximum number of iterations to run the simulation. If None, the simulation runs infinitely.

  • homophily_threshold (float, default=0.2) – The threshold for homophily. If the difference in opinions between two agents is less than this value, they interact.

  • mu (float, default=0.5) – The convergence rate of the agents.

  • use_network (bool, default=False) – For using a square lattice network. Will throw error if sqrt(n_agents) is not an integer.

  • rng_seed (int, default=None) – The seed for the random number generator. If not provided, a random seed is picked.

  • agent_file (str, default=None) – The file to read the agents from. If None, the agents are generated randomly.

  • network_file (str, default=None) – The file to read the network from. If None, the network is generated randomly

  • other_settings (Other_Settings, default=None) – The other settings for the simulation. If None, the default settings are used.

Network#

The network generated by the simulation.

Type:

Network (Object)

Opinion#

The opinions of the agents or nodes of the network.

Type:

Float

property Network#

Access the network generated by the simulation.

Returns:

The network generated by the simulation.

Return type:

seldoncore.Network

agent_opinion(index: int = None)#

Access the agents data from the simulation.

Parameters:

index (int) – The index of the agent to access. The index is 0-based. If not provided, all agents are returned.

print_settings()#

Print the settings of the simulation.

run(output_dir: str = None)#

Run the simulation.

Parameters:

output_dir (str, default="./output") – The directory to output the files to.

set_agent_opinion(index: int, opinion: float)#

Set the opinion of a specific agent.

Parameters:
  • index (int) – The index of the agent whose opinion is to be set.

  • opinion (float) – The new opinion value for the agent.