gabm.abm.group module
- class gabm.abm.group.Group(group_id: GroupID, name: str = None)
Bases:
objectA Group is a collection of Agents that can interact with each other and the environment.
- Attributes:
id (GroupID): Unique identifier for the group. name (str): Optional name for the group. members (Set[Agent]): A set of Agent instances that are members of the group.
- add_member(agent: Agent)
Add agent to the group and update the agent’s group membership.
- Args:
agent: The Agent instance to add to the group.
- list_members()
- Return:
A new tuple of the members.
- class gabm.abm.group.GroupID(group_id: int)
Bases:
GABMIDA unique identifier for a Group instance.
- Attributes:
group_id (int): The unique identifier for the group.
- class gabm.abm.group.OpinionatedGroup(group_id: GroupID, name: str = None, opinions: dict = None)
Bases:
GroupA Group that has opinions.
- Attributes:
- opinions: A dictionary of Opinions.
The keys are OpinionTopicIDs, and the values are Opinion objects. This allows the group to have its own opinions, which can be influenced by its members and can also influence its members.
- get_AverageOpinion(opinion_topic_id: OpinionTopicID) float
Get the average opinion value of the group members on a specific topic.
- Args:
opinion_topic_id: The opinion topic ID to get the average opinion on.
- Returns:
The average opinion value for the topic, or None if no members have an opinion on it.