Community

The main module a simulation of a community.

class __init__.Community

This is the main object for simulating HIV in a community.

add_to_grid_queue(agent)

Find the appropriate grid queue for agent. Called by 1. Time Operator - when agent graduates to the next grid queue 1.5 Time Operator - when relationship with removed is dissolved 2. Relationship Operator - a relationship is dissolved 3. Community - in make_population in the mainloop

add_to_simulation(agent)

Add agent to the list of agents, the network, and assign to a grid queue. This is seperate from the make_population method so that other objects can add agents without make_population.

age(agent)

Finds the age of agent

cleanup()

Send a ‘terminate’ signal to all of the Grid Queues. Update end values in relationships (to account for deaths).

hazard(agent1, agent2, **attributes)

Calculates and returns the hazard of relationship formation between agent1 and agent2. If age_difference or mean_age is None (i.e. not provided), this function will calculate it.

make_operators()

Creates the operators necessary for the simulation.

make_population(size)

Creates size agents with age, sex, and desired number of partners (DNP) dictated by born, sex, and dnp (functions). If these these are omitted, default distributions will be used.

After an agent receives a name, age, sex, and DNP, he or she is added to the network graph and added to a grid queue.

run(timing=False)

Runs the mainloop of the simulation. Clear all data structures, make agents, and iterate through time steps.

start()

Initializes the data structures and operators. This allows users to set simulation variables and still have initialization of data structures independent from the run method.

step()

Take a single time step (one week) in the simulation.

Previous topic

Tutorial

Next topic

Operators

This Page