Actor
This is an overview over the Actor Class
- class pop2net.Actor(*args, **kwargs)[source]
This is a Base class to represent actors in the simulation.
Actors’ behavior can be implemented in classes that inherit from this.
- add_location(location, weight=None)[source]
Add this actor to a given location. If weight is None, it will be set to 1.
- connect(actor, location_cls=None, weight=None)[source]
Connects this actor with a given other actor via an instance of a given location class. If location_cls is None, the default pop2net.Location class is used to create a new location instance. If weight is None, it will be set to 1.
- disconnect(neighbor, location_labels=None, remove_self=True, remove_neighbor=True, remove_locations=False)[source]
Disconnects this actor from a given other actor 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 actors from the given location instance but also to remove the location instance from the model. Keep in mind that this may affect other actors that are still connected with the location instance.
- Parameters:
neighbor (Actor) – An actor 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 actor 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_actor_weight(actor, location_labels=None)[source]
Returns the edge weight between this actor and a given other actor.
This is summed over all shared locations.
- get_location_weight(location)[source]
Return the edge weight between this actor and a given location.
- Parameters:
location (_type_) – A location.
- Returns:
The edge weight.
- Return type:
- property location_labels: list[str]
Returns a list of labels of the locations this actor is associated with.
- property locations: list
Returns a list of locations that this actor is associated with.
- Returns:
A list of locations.
- neighbors(location_labels=None)[source]
Return all neighbors of an actor.
Convenience method that returns all neighbors over all locations this actor is currently located in. The locations to be considered can be defined with location_labels.
Returns all locations that this actor shares with another actor. Use location_labels to specify which type of locations should be included in the search for shared locations.