Focal agent (simulation component)

This component is concerned with selecting the focal agent (i.e. the agent who sends their attribute value) at each timestep in the simulation run.

The following methods are available:

focal_agent_sim module

defSim.focal_agent_sim.focal_agent_sim.select_focal_agent(network: networkx.classes.graph.Graph, realization: str, agents: List[int] = [], **kwargs) → int

This function works as a factory method for the FocalAgentSelector component. It calls the select_agent function of a specific implementation of the FocalAgentSelector and passes to it the kwargs dictionary.

Parameters
  • network – A NetworkX object from which the focal agent will be selected

  • realization – The specific FocalAgentSelector that shall be used to sample the focal agent. Options are “random”, …

  • agents – A list of the indices of all agents in the network.

:returns The index of the focal agent in the network.


Abstract Base Class (ABC)

class defSim.focal_agent_sim.focal_agent_sim.FocalAgentSelector(**kwargs)

Bases: abc.ABC

This class is responsible for sampling the focal agent for the influence process.

__init__(**kwargs)
Parameters

kwargs – This dictionary contains all the implementation-specific parameters.

abstract select_agent(agents: List[int] = []) → int

This method selects an agent from a network for the influence process. Based on the communication regime, the selected agent is either the source or the target of influence.

Parameters
  • network – A NetworkX object from which the agent shall be selected.

  • agents – A list of the indices of all agents in the network

:returns The index of the selected agent.