Influence (simulation component)

The following methods are available

User-written extensions can be found in Extensions.. Currently, the following methods are available:

influence_sim module

defSim.influence_sim.influence_sim.spread_influence(network: networkx.classes.graph.Graph, realization: str, agent_i: int, agents_j: List[int], regime: str, dissimilarity_measure: defSim.dissimilarity_component.dissimilarity_calculator.DissimilarityCalculator, attributes: Optional[List[str]] = None, **kwargs) → bool

This function works as a factory method for the influence component. It calls either the many_to_one or the one_to_many function of a specific implementation of the InfluenceOperator and passes the arguments and the kwargs dictionary.

Parameters
  • network – A NetworkX object that will be modified.

  • realization – The specific implementation of the InfluenceOperator. Options are “bounded_confidence”, “similarity_adoption”, “weighted_linear”, “persuasion”. Alternatively, a user-written implementation of the abstract base class can be given here.

  • agent_i – the index of the focal agent that is either the source or the target of the influence

  • agents_j – A list of indices of the agents who can be either the source or the targets of the influence.

  • attributes – A list of the names of all the attributes that are subject to influence. If an agent has e.g. the attributes “Sex” and “Music taste”, only supply [“Music taste”] as a parameter for this function. The influence function itself can still be a function of the “Sex” attribute.

  • regime – Either “many_to_one”, “one_to_many” or “one_to_one”.

  • dissimilarity_measure – An instance of a DissimilarityCalculator.

Returns

true if agent(s) were successfully influenced


Abstract Base Class (ABC)

class defSim.influence_sim.influence_sim.InfluenceOperator(regime: str, **kwargs)

Bases: abc.ABC

The InfluenceOperator is responsible for executing the influence function of the simulation. The influence function can be something like bounded confidence, negative influence or only positive influence.

__init__(regime: str, **kwargs)
Parameters
  • regime – This string determines the mode in which the agents influence each other. In ‘one-to-one’ the focal agent influences one other agent, in ‘one-to-many’ multiple other agents and in ‘many-to-one’ the focal agent is influenced by multiple other agents in the network.

  • kwargs – Additional parameters specific to the implementation of the InfluenceOperator

abstract spread_influence(network: networkx.classes.graph.Graph, agent_i: int, agents_j: List[int], dissimilarity_measure: defSim.dissimilarity_component.dissimilarity_calculator.DissimilarityCalculator, attributes: Optional[List[str]] = None, **kwargs) → bool

This function is responsible for executing the influence process. The call of this function can be seen as an interaction between agents that either results in successful influence or not. Unsuccessful influence attempts can also be interpreted as no interaction at all. The function returns true if influence was successful. :param network: A NetworkX object in which the agents exist. :param agent_i: the index of the focal agent that is either the source or the target of the influence :param agents_j: A list of indices of the agents who can be either the source or the targets of the

influence. The list can have a single entry, implementing one-to-one communication.

Parameters
  • attributes – A list of the names of all the attributes that are subject to influence. If an agent has e.g. the attributes “Sex” and “Music taste”, only supply [“Music taste”] as a parameter for this function. The influence function itself can still be a function of the “Sex” attribute.

  • dissimilarity_measure – An instance of a DissimilarityCalculator.

Returns

true if agent(s) were successfully influenced