WeightedLinear

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

Bases: defSim.influence_sim.influence_sim.InfluenceOperator

The weighted linear influence function implements the experienced opinion shift as a function of the pre-interaction cultural or opinional distance between the agents involved. The homophily parameter controls the steepness of the attraction/repulsion curve. Formally:

\[o_{i,t+1} = o_{i,t} + \textrm{convergence_rate} \cdot (1 - \textrm{homophily} | o_{j} - o_{i,t} |) ( o_{j} - o_{i,t} )\]

Thereafter, opinions are bounded such that they never fall outside the range \([0,1]\)

Note that the focal agent in one-to-one and one-to-many interaction is the sending agent, indicated as agent j, and refers to the receiving agent, indicated as agent i, under many-to-one interaction.

Crucial is the homophily parameter. The higher its value, the smaller the shift of the receiving agent in the direction of the sending agent will be. With this parameter, we can integrate ideas of positive, moderated positive, and negative influence into one functional model.

Three critical values for the homophily parameter:

  • homophily == 0: only positive influence, the agents exhibit no preference for like-minded others.

  • homophily > 0: moderated positive influence, the agents exhibit a preference for like-minded others and move less towards the sender as their distance increases.

  • homophily > 1: moderated postive influence AND negative influence, the agents exhibit a preference for like-minded others and move less towards the sender as their distance increases, until distance \(1 / \textrm{homophily}\) where agents experience a push away from the sending agent.

__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. Possible parameters are the following:

  • convergence_rate (float=0.5) – A number between 0 and 1 determining what proportion of the sending agent’s position the receiving agent will adopt. E.g. when set to 1, the receiving agent assimilates - adopting the sending agent’s position fully, but when set to 0.5, the receiving agent moves only half-way towards the sending agent’s position. Passed as a kwargs argument.

  • homophily (float=0) – A number \(\geq\) 0 that controls the shape of the influence curve. At 0, agents do not show a preference for similar others (only positive influence). At 1, agents more strongly adjust their opinion when confronted with similar others (moderated positive influence). At values > 1, there exists a point at which influence becomes negative, making agents shift away from the sending agents expressed opinion.

  • influence_modifiers (List[str]=[]) – Modifiers to apply to weighted linear influence. Select from [smooth”, “stubborn”]

  • bi_directional (bool=False) – A boolean specifying whether influence is bi- or uni-directional.

_abc_impl = <_abc._abc_data object>
_apply_smoothing(base_influence: float, target: int, influenced_feature: str, network: networkx.classes.graph.Graph)

This function applies smoothing to the influence exerted on a target. The smoothing results in reduced change in the direction of the closest extreme [FlacheMacy2011]. To illustrate: If the base influence is positive and the agent’s opinion is at the lower bound of the scale, full influence is exerted. If base influence is positive and the agent’s opinion is at the upper bound of the scale, no influence is exerted. Intermediate feature values lead to reduced but nonzero influence.

Parameters
  • base_influence – Non-smoothed influence exerted on target

  • target – Agent to influence

  • influenced_feature – Feature to influence on agent

  • network – Network in which the agent exists

Returns

Influence value after smoothing has been applied

_apply_stubbornness(base_influence: float, target: int, influenced_feature: str, network: networkx.classes.graph.Graph)

This function applies stubbornness to the influence exerted on a target. The stubbornness results in reduced change for agents with more extreme feature values. To illustrate: If the agent’s feature value is exactly between the upper and lower bound, full influence is exerted. If the agent’s feature value is exactly at the upper or lower bound, no influence is exerted. :param base_influence: Non-smoothed influence exerted on target :param target: Agent to influence :param influenced_feature: Feature to influence on agent :param network: Network in which the agent exists :returns: Influence value after stubbornness has been applied

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
Parameters
  • network – The network in which the agents exist.

  • 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. The list can have a single entry, implementing one-to-one communication.

  • 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

References

FlacheMacy2011

Flache, A., & Macy, M. W. (2011). Small Worlds and Cultural Polarization. The Journal of Mathematical Sociology, 35(1–3), 146–176. https://doi.org/10.1080/0022250X.2010.532261 + Corrigendum