Base Model¶
This module contains the definition of simulation Models. It has an abstract definition BaseModel, that should be extended, implementing its abstract methods.
Example
Creating a model:
class Model(BaseModel):
def get_output(self) -> int:
return self.get_state()
def state_transition(self, x: int, y: int):
self.set_up_state(x + y)
-
class
gsf.models.core.base_model.
BaseModel
¶ Bases:
gsf.core.entity.core.entity.Entity
Base model in a dynamic system
- Parameters
dynamic_system (BaseDynamicSystem) – Dynamic system of the model.
name (str) – Name of the model.
state (ModelState) – Initial state of the model.
entity_manager (EntityManager) – Delegated entity manager.
-
_serial_id
¶ Serial of the model.
- Type
int
-
__current_dynamic_system
¶ Current dynamic system of the model.
- Type
-
__current_state
¶ Current state of the model.
- Type
ModelState
-
add
()¶ Current model will be the input for the given model.
- Parameters
model (BaseModel) – Output model to be added.
weight (ExpressionProperty) – Weight of the path.
name (str) – Name of the path.
-
get_dynamic_system
()¶ Returns the dynamic system where the current model belongs with
-
abstract
get_output
() → Any¶ Gets the output of the model.
-
get_state
()¶ Returns the curren state,
-
remove
()¶ Removes the model from the dynamic system
-
set_up_state
()¶ Sets up the state of the model.
- Parameters
state (ModelState) – New state of the model.
-
abstract
state_transition
(*args, **kwargs)¶ Executes the state transition function
-
gsf.models.core.base_model.
ModelState
= typing.Any¶ State of a model type.