Grid Queue

The module for the GridQueue class and function for listening.

class GridQueue.GridQueue(top, bottom, sex, index)

A data structure for holding agents of similar age and sex.

accepts(agent)

Returns whether agent is qualified for this grid queue.

add(agent)

Add agent to the priority queue.

age(agent)

Returns the age of the agent

contains(agent_name)

Returns whether this grid queue contains an agent with the name agent_name.

enquire(suitor)

Returns the agent name of an agent who would form a relationship with suitor. Returns None if there are no agents, or none of the agents in the grid queue don’t accept.

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.

recruit()

Returns the agent name from the queue that has been waiting the longest. Returns None if there are no agents in the queue, or all the agents in it’s queue have been returned this round.

remove(agent_name)

Remove the agent with the name agent_name from the priority queue.

GridQueue.listen(gq, pipe)

Listens for an action from pipe to perform on gq. semaphore object passed by relationship operator which creates it – allows simulation to use less than all the cores of the machine.

Previous topic

Operators

Next topic

Agent

This Page