Discrete Time Model

This module contains the definition of a discrete time simulation Model. It has an abstract definition DiscreteTimeModel, that should be extended, implementing its abstract methods.

Example

Creating a model:

class Cell(DiscreteTimeModel):
    _symbol: str

    def __init__(
        self,
        dynamic_system: DiscreteEventDynamicSystem,
        state: bool,
        symbol: str = None,
    ):
        super().__init__(dynamic_system, state=state)
        self._symbol = symbol or "♥"

    def _state_transition(self, state: bool, inputs: Dict[BaseModel, bool]) -> bool:
        next_state: bool = list(inputs.values())[0]
        return next_state

    def _output_function(self, state: bool) -> bool:
        return state

    def __str__(self):
        is_alive = self.get_state()
        if is_alive:
            return self._symbol
        return "-"
class gsf.models.models.discrete_time_model.DiscreteTimeModel(dynamic_system: gsf.dynamic_system.dynamic_systems.discrete_event_dynamic_system.DiscreteEventDynamicSystem, name: Optional[str] = None, state: Optional[Any] = None, entity_manager: Optional[gsf.core.entity.core.entity_manager.EntityManager] = None)

Bases: gsf.models.models.discrete_event_model.DiscreteEventModel

Discrete-time views values of variables as occurring at distinct, separate “points in time”, or equivalently as being unchanged throughout each non-zero region of time, time is viewed as a discrete variable

abstract _state_transition(state: Any, inputs: Dict[str, Any])Any

Executes the state transition using the current state of the model.

\delta \; : \; S \; x \; X \longrightarrow S

Parameters
  • state (ModelState) – Current state of the model.

  • inputs (ModelInput) – Input trajectory x.