ModelDF#
- class mesa_frames.ModelDF(seed: int | Sequence[int] | None = None)[source]#
Base class for models in the mesa-frames library.
This class serves as a foundational structure for creating agent-based models. It includes the basic attributes and methods necessary for initializing and running a simulation model.
Methods:
Create a new model.
Retrieve the AgentSetDF of a specified type.
Reset the model random number generator.
Run the model until the end condition is reached.
Run a single step.
Attributes:
Get the AgentsDF object containing all agents in the model.
Get a list of different agent types present in the model.
Get the space object associated with the model.
- __init__(seed: int | Sequence[int] | None = None) None [source]#
Create a new model.
Overload this method with the actual code to start the model. Always start with super().__init__(seed) to initialize the model object properly.
- get_agents_of_type(agent_type: type) AgentSetDF [source]#
Retrieve the AgentSetDF of a specified type.
- Parameters:
agent_type (type) – The type of AgentSetDF to retrieve.
- Returns:
The AgentSetDF of the specified type.
- Return type:
AgentSetDF
- reset_randomizer(seed: int | Sequence[int] | None) None [source]#
Reset the model random number generator.
- step() None [source]#
Run a single step.
The default method calls the step() method of all agents. Overload as needed.
- property agents: AgentsDF#
Get the AgentsDF object containing all agents in the model.
- Returns:
The AgentsDF object containing all agents in the model.
- Return type:
AgentsDF
- Raises:
ValueError – If the model has not been initialized properly with super().__init__().
- property space: SpaceDF#
Get the space object associated with the model.
- Returns:
The space object associated with the model.
- Return type:
SpaceDF
- Raises:
ValueError – If the space has not been set for the model.