Actors Container
Bases: _AgentsContainer
AgentsContainer for the MainModel.
Source code in abses/container.py
register ¶
Registers a new breed of actors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
actor_cls |
Type[Actor]
|
The class of the actor to register. It can be a single class, or an iterable of classes. Once a breed is registered, it will be added to all the containers of the model globally. It means, it's not necessary to register the same breed again. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the breed is already registered. |
Source code in abses/container.py
new ¶
Create one or more actors of the given breed class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
breed_cls |
Type[Actor]
|
The breed class of the actor(s) to create. |
Actor
|
num |
Optional[int]
|
The number of actors to create. Defaults to 1. |
None
|
singleton |
bool
|
Whether to create a singleton actor. Defaults to False. |
False
|
**kwargs |
Any
|
Additional keyword arguments to pass to the actor constructor. |
{}
|
Returns:
Type | Description |
---|---|
Union[Actor, ActorsList[Actor]]
|
The created actor(s). |
Example
Source code in abses/container.py
new_from_graph ¶
Create a set of new agents from networkx graph.
Source code in abses/container.py
new_from_gdf ¶
Create actors from a geopandas.GeoDataFrame
object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gdf |
GeoDataFrame
|
The |
required |
unique_id |
Optional[str]
|
A column name, to be converted to unique index of created geo-agents (Social-ecological system Actors). |
None
|
agent_cls |
type[Actor]
|
Agent class to create. |
Actor
|
Raises:
Type | Description |
---|---|
ValueError
|
If the column specified by |
Returns:
Type | Description |
---|---|
ActorsList[Actor]
|
An |
Source code in abses/container.py
Bases: _AgentsContainer
Container for agents located at cells.
Source code in abses/container.py
remove ¶
Remove the given agent from the cell.
Generally, it stores all the agents on this cell.
Therefore, it is not recommended to use this method directly.
Consider to use actor.move.off()
to let the actor leave this cell instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent |
Actor
|
The agent (actor) to remove. |
required |
Raises:
Type | Description |
---|---|
ABSESpyError
|
If the agent is not on this cell. |
Source code in abses/container.py
new ¶
Creates a new actor or a list of actors of the given breed class. The created actors are added to both the cell and the model's global container.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
breed_cls |
Type[Actor]
|
The breed class of the actor(s) to create. |
Actor
|
num |
int
|
The number of actors to create. Defaults to 1. |
1
|
singleton |
bool
|
Whether to create a singleton actor. Defaults to False. |
False
|
**kwargs |
Any
|
Additional keyword arguments to pass to the actor constructor. |
{}
|
Returns:
Type | Description |
---|---|
Actor | ActorsList
|
The created actor(s). |