Agent
This is an overview over the Agent Class
- class pop2net.Agent(model, *args, **kwargs)[source]
This is a Base class to represent agents in the simulation.
Agents’ behavior can be implemented in classes that inherit from this.
Examples
For instance, agents could all be instatiated with the is_infected attribute set to false:
class InfectionAgent(Agent): def setup(self): self.is_infected = False
- connect(agent, location_cls, weight=None)[source]
Connects this agent with a given other agent via an instance of a given location class.
- disconnect(neighbor, location_labels=None, remove_self=True, remove_neighbor=True, remove_locations=False)[source]
Disconnects this agent from a given other agent by removing them from shared locations.
If a list of location types is given, only shared locations of the given types are considered. Turn on remove_locations in order to not only remove the agents from the given location instance but also to remove the location instance from the model. Keep in mind that this may affect other agents that are still connected with the location instance.
- Parameters:
neighbor (Agent) – An agent to disconnect from.
location_labels (list | None, optional) – A list of location types to specify which
None. (shared locations are considered. Defaults to)
remove_self (bool) – Should the agent be removed from the shared locations? Defaults to True.
remove_neighbor (bool) – Should the neighbor be removed from the shared locations? Defaults to True.
remove_locations (bool, optional) – A bool that determines whether the shared locations shall be removed from the model. Defaults to False.
- get_agent_weight(agent, location_labels=None)[source]
Return the edge weight between this agent and a given other agent.
This is summed over all shared locations.
- get_location_weight(location)[source]
Return the edge weight between this agent and a given location.
- Parameters:
location (_type_) – A location.
- Returns:
The edge weight.
- Return type:
- property locations: LocationList
Return a list of locations that this agent is associated with.
- Returns:
A list of locations.
- neighbors(location_labels=None)[source]
Return all neighbors of an agent.
Convenience method that returns all neighbors over all locations this agent is currently located in. The locations to be considered can be defined with location_labels.