scicom.historicalletters.agents

The agent classes for HistoricalLetters.

Classes

SenderAgent

The agent sending letters.

RegionAgent

The region keeping track of contained agents.

Module Contents

class scicom.historicalletters.agents.SenderAgent(model, geometry, crs, similarityThreshold, moveRange, letterRange)

Bases: mesa_geo.GeoAgent

The agent sending letters.

On initialization an agent is places in a geographical coordinate. Each agent can send letters to other agents within a distance determined by the letterRange. Agents can also move to new positions within the moveRange.

Agents keep track of their changing “interest” by having a vector of all held positions in topic space.

Parameters:
  • model (mesa.Model)

  • geometry (shapely.geometry.point.Point)

  • crs (str)

  • similarityThreshold (float)

  • moveRange (float)

  • letterRange (float)

region_id = ''
activationWeight = 1
similarityThreshold
moveRange
letterRange
topicVec = ''
topicLedger = []
numLettersReceived = 0
numLettersSend = 0
move(neighbors)

Agent can randomly move to neighboring positions.

Neighbours with a higher number of received letters are more likely targets of a movement process. The amount of movement is randomly drawn.

Parameters:

neighbors (list)

Return type:

None

has_letter_contacts(*, neighbors=False)

List of already established and potential contacts.

Implements the ego-reinforcing by allowing mutliple entries of the same agent. In neighbourhoods agents are added proportional to the number of letters they received, thus increasing the reinforcement. The range of the visible neighborhood is defined by the letterRange parameter during model initialization.

For neigbors in the social network (which can be long-tie), the same process applies. Here, at the begining of each step a list of currently valid scalings is created, see step function in model.py. This prevents updating of scales during the random activations of agents in one step.

Parameters:

neighbors (list)

Return type:

list

chooses_topic(receiver)

Choose the topic to write about in the letter.

Agents can choose to write a topic from their own ledger or in relation to the topics of the receiver. The choice is random.

Parameters:

receiver (str)

Return type:

tuple

sendLetter(neighbors)

Send a letter based on an urn model.

Parameters:

neighbors (list)

Return type:

None

step()

Perform one simulation step.

Return type:

None

class scicom.historicalletters.agents.RegionAgent(model, geometry, crs)

Bases: mesa_geo.GeoAgent

The region keeping track of contained agents.

This agent type is introduced for visualization purposes. SenderAgents are linked to regions by calculation of a geographic overlap of the region shape with the SenderAgent position. At initialization, the regions are populated with SenderAgents giving rise to a dictionary of the contained SenderAgent IDs and their initial topic. At each movement, the SenderAgent might cross region boundaries. This reqieres a re-calculation of the potential overlap.

Parameters:
  • model (mesa.Model)

  • geometry (shapely.geometry.polygon.Polygon)

  • crs (str)

senders_in_region
main_topic: tuple
has_main_topic()

Return weighted average topics of agents in region.

Return type:

tuple

add_sender(sender)

Add a sender to the region.

Parameters:

sender (SenderAgent)

Return type:

None

remove_sender(sender)

Remove a sender from the region.

Parameters:

sender (SenderAgent)

Return type:

None