gabm.abm.attribute module

Generic attribute base classes for GABM.

class gabm.abm.attribute.GABMAttribute(id: GABMID, description: str)

Bases: object

Generic base class for attributes (e.g., Gender, Health).

Attributes:

id: Unique identifier object (e.g., GenderID, HealthID). description (str): Description of the attribute.

class gabm.abm.attribute.GABMAttributeID(attribute_id: int)

Bases: GABMID

Identifier for GABM attributes.

Attributes:

id (int): The unique identifier.

class gabm.abm.attribute.GABMAttributeMap(items: dict[GABMID, GABMAttribute])

Bases: object

Generic base class for attribute maps (e.g., GenderMap, HealthMap).

Attributes:

_map (dict): Mapping from ID objects to attribute instances.

T = ~T
add(attr: GABMAttribute)

Add an attribute to the map.

Args:

attr: An instance of an attribute (e.g., Gender, Health).

get(id: GABMID)
Return:

The attribute instance for the given ID object, or None if not found.

items()
Return:

An iterable of (ID object, attribute instance) pairs in the map.

keys()
Return:

An iterable of the ID objects in the map.

values()
Return:

An iterable of the attribute instances in the map.