Main Model
Bases: Generic[H, N]
, Model
, _Notice
, _States
Base class of a main ABSESpy model.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
name of the model. By default, it's the lowercase of class name. E.g.: TestModel -> testmodel. |
settings |
DictConfig
|
Structured parameters of the model. Other module or submodules can search the configurations here structurally.
For an example, if the settings is a nested DictConfig like {'nature': {'test': 3}}, users can access the parameter 'test = 3' by |
human |
Union[H, BaseHuman]
|
The Human module. |
nature |
Union[N, BaseNature]
|
The nature module. |
time |
TimeDriver
|
Time driver. |
params |
DictConfig
|
Parameters of the model, having another alias |
run_id |
int | None
|
The run id of the current model. It's useful in batch run. |
agents |
_ModelAgentsContainer
|
The container of all agents. One model only has one specific container where all alive agents are stored. |
actors |
ActorsList[Actor]
|
All agents on the earth (added to a specific PatchCell) as a list. A model can create multiple lists referring different actors. |
Source code in abses/main.py
run_id
property
¶
The run id of the current model. It's useful in batch run. When running a single model, the run id is None.
settings
property
¶
Structured parameters of the model. Other module or submodules can search the configurations here structurally.
For an example, if the settings is a nested DictConfig like {'nature': {'test': 3}},
users can access the parameter 'test' by both ways:
1. model.nature.params.test
.
2. model.nature.p.test
.
agents
property
¶
The container of all agents. One model only has one specific container where all alive agents are stored. Users can access, manipulate, and create agents by this container:
For instances:
1. model.agents.get()
to access all agents.
2. model.agents.new(Actor, num=3)
to create 3 agents of Actor.
3. model.agents.register(Actor)
to register a new breed of agents to the whole model.
4. model.agents.trigger()
to trigger a specific event to all agents.
actors
property
¶
All agents on the earth as an ActorList
.
A model can create multiple lists referring different actors.
run_model ¶
Start running the model.
In order, the model will go through the following steps:
1. Call model.setup()
method.
2. Call model.step()
method.
3. Repeating steps, until the end situation is triggered
4. Call model.end()
method.
Source code in abses/main.py
setup ¶
step ¶
end ¶
summary ¶
Report the state of the model.