LocationDesigner

The LocationDesigner class is an interface to design specific network structures using the Creator.

class pop2net.LocationDesigner(model)[source]

Helper class to create locations from inside the Creator.

bridge(agent)[source]

Create locations with one agent for each unique value returned.

Cannot be used in combination with melt().

Parameters:

agent (_agent.Agent) – The agent that is currently processed by the Creator.

Returns:

The value which is used to assign agents to location instances.

Return type:

float | str | list | None

filter(agent)[source]

Check whether the agent is meant to join this type of location.

Parameters:

agent (Agent) – The agent that is currently processed by the Creator.

Return type:

bool

Returns:

True if the agent is allowed to join the location, False otherwise. Returns True by default.

melt()[source]

Allows to assign agents with different attribute values to the same location.

Merges the agents assigned to the instances of the returned location classes into one instance of this location class.

Returns:

A list or tuple of location classes.

Return type:

None | list | tuple

mutate()[source]

Creates new versions of this location designer with different attributes.

Returns:

A dictionary that specifies the values for each mutation.

Return type:

dict

nest()[source]

Nests this location class into another location class.

Ensures that the agents assigned to the same instance of this location class are also assigned to the same instance of the returned location class.

Returns:

The location class in which this location class should be nested.

Return type:

type[Location] | None

setup()[source]

Use this method to set instance attributes, for instance.

This method is called automatically by the creator after creating an instance.

Return type:

None

split(agent)[source]

Creates seperate location instances for each unique returned value.

Parameters:

agent (Agent) – The agent that is currently processed by the Creator.

Returns:

The value(s) that determine(s) to which location instance the agent is assigned.

Return type:

float | str | list | None

stick_together(agent)[source]

Assigns agents with a shared value on an attribute to the same location instance.

Parameters:

agent (_agent.Agent) – The agent that is currently processed by the Creator.

Returns:

A value that defines the groups of agents.

Return type:

float | str