Location

The location class represents a base class that can be used to implement realistic location in which agents can meet and interact.

class pop2net.Location(*args, **kwargs)[source]

Base class for location objects.

property actors: list

Return the list of actors affiliated with this location.

Returns:

List of actors at this location.

add_actor(actor, weight=None)[source]

Assigns the given actor to this location.

Parameters:
  • actor (Actor) – The actor that should be added to the location.

  • weight (Optional[float]) – The edge weight between the actor and the location. Defaults to None. If weight is set to None, the weight is generated by location.weight(), which returns 1 by default.

Return type:

None

add_actors(actors, weight=None)[source]

Add multiple actors at once.

Parameters:
  • actors (list) – An iterable over actors.

  • weight (float | None) – The edge weight between the actors and the location. Defaults to None. If weight is set to None, the weight is generated by location.weight(), which returns 1 by default.

Return type:

None

get_weight(actor)[source]

Return the edge weight between an actor and the location.

Parameters:

actor (Actor) – Actor of which the edge weight should be returned.

Return type:

float

Returns:

Edge weight.

neighbors(actor)[source]

Returns a list of actors which are connected to the given actor via this location.

Parameters:

actor (_actor.Actor) – Actor of whom the neighbors at this location are to be returned.

Returns:

A list of all actors at this location except the passed actor.

Return type:

ActorList

project_weights(actor1, actor2)[source]

Calculates the edge weight between two actors assigned to the same location instance.

Defines how the weights are combined when the edge weight between two actors is determined. Can be completely rewritten to have location-specific methods of this kind with the same name or can be used as it is in the simulation code.

Parameters:
  • actor1 (Actor) – First actor of the pair.

  • actor2 (Actor) – Second actor of the pair.

Raises:

Exception – Raised if self.weight_projection_function is not in [“average”, “simultan”]

Return type:

float

Returns:

Combined edge weight.

remove_actor(actor)[source]

Removes the given actor from this location.

Parameters:

actor (Actor) – Actor that is to be removed.

Return type:

None

remove_actors(actors)[source]

Remove multiple actors at once.

Parameters:

actors (list) – An iterable over actors.

Return type:

None

set_weight(actor, weight=None)[source]

Set the weight of an actor at the current location.

If weight is None the method location.weight() will be used to generate a weight.

Parameters:
  • actor (Actor) – The actor.

  • weight (float) – The weight.

Return type:

None

weight(actor)[source]

Generates the edge weight between a given actor and the location instance.

Parameters:

actor (_type_) – An actor.

Returns:

The weight between the given actor and the location.

Return type:

float