Deffuant Vector Model#

The Deffuant Vector Model extends the traditional Deffuant Model to multi-dimensional binary vectors. In this model, each agent’s opinion is represented as a binary vector, where each dimension of the vector can have a value of either 0 or 1. The model describes how agents adjust their binary opinions through random binary encounters, similar to the classical Deffuant approach.

Model Dynamics#

Binary Opinions:

Each opinion is represented as a binary vector, where the values are restricted to 0 or 1. The interaction and adjustment process involves comparing these vectors and updating them based on the Homophily Threshold.

Homophily Threshold:

Agents will only adjust their opinions if the difference between their opinion vectors is below a specified threshold. This difference is computed in a way that considers the multi-dimensional nature of the opinion vectors.

The Deffuant Model provides insight into how personal interactions and opinion thresholds influence the dynamics of opinion formation and clustering within a group of agents.

Example:#

>>> from pyseldonlib import Deffuant_Vector_Model
>>> # Create the Deffuant Vector Model
>>> deffuant = Deffuant_Vector_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.DeffuantVectorModel.Deffuant_Vector_Model(max_iterations: int = None, homophily_threshold: float = 0.2, mu: float = 0.5, use_network: bool = False, dim: int = 1, 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 Vector 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 if sqrt(n_agents) is not an integer.

  • dim (int, default=1) – For the multi-dimensional binary vector Deffuant model, define the number of dimensions in each opinion vector

  • 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.