Simulation Structure
The rationale behind the FERAL core is to provide a simulation framework that enables the rapid integration of various simulation models, specifically Models of Computation and Communication (MOCC). This core allows for the creation of numerous simulation applications. FERAL constructs a hierarchical tree of components, as illustrated in Figure 1. This tree begins with a root component and includes intermediate components, often referred to as directors, which define the MOCC. These intermediate components can contain other components, creating a nested structure. Leaf components, which are the simulation components, are at the end of this hierarchy. They contain ports that serve as endpoints for inter-component communication. The execution of each simulation component is managed by its nearest parent director, and the execution of a director is controlled by its parent director.
FERAL Component Tree¶
Figure 2 outlines the main components of a FERAL simulation. Each simulation consists of a scenario and a root director. The scenario sets the overall aspects of the simulation, such as user interaction and remote control capabilities. The root director is a runnable component, usually representing the top-level MOCC of the simulation. A MOCC defines the execution and communication semantics for its controlled components.
Main Components of a FERAL Simulation¶
Due to the complexity of some simulations, a single MOCC is often insufficient. Therefore, FERAL supports the hierarchical coupling of multiple MOCCs. Nested simulation directors define MOCCs within their parent director, allowing any number of MOCCs to be nested. The execution of a nested MOCC is managed by its parent director. For instance, if a simulation director is placed inside a Real-Time director that synchronizes simulation times with the wall-clock time, the nested simulation directors will also synchronize with the wall-clock time to the extent possible.
FERAL simulation components act as a bridge between a MOCC and simulation workers. Both components and workers are typically tailored to a specific MOCC. Simulation workers integrate behavior and simulation models into the FERAL framework. FERAL provides worker classes for most MOCCs, enabling the implementation of simulation models according to the semantics of each MOCC.
Most workers utilize the generic simulation component of their MOCC to simplify integration. The default behavior of the MOCC simulation component is generally adequate for most scenarios. However, using the simulation component as a bridge allows for the customization of interactions by creating tailored simulation components.
Existing simulators and behaviors are integrated into FERAL by subclassing a worker class. Simulation workers interact with the simulation component to access MOCC functions, ensuring that the execution and communication of a simulation worker conform to the MOCC.
FERAL facilitates inter-component communication through ports. It defines input and output ports, as well as bidirectional ports that enable communication in both directions. Links connect output ports to input ports, transporting communication messages. All communication between ports in FERAL is conducted via explicit and typed communication messages.
The following basic example scenario demonstrates the structure of a FERAL simulation and the main components involved.
This example is a discrete time simulation with one producer component (ValueProducerDT
) that repeatedly generates messages and a sink component (SinkDT
) that consumes these messages.
A link connects the output port of the producer to the input port of the consumer.
Example Scenario
from feral3gp import feral as feral
from feral3gp.feral import seconds
from feral3gp.feral.presets.producer.value_producer import ValueProducerDT
from feral3gp.feral.presets.sink.sink import SinkDT
producer = ValueProducerDT("Sender")
sink = SinkDT("Sink")
feral.link(producer, "output", sink, "input")
feral.set_step_size(seconds(1))
feral.start(seconds(10))
By leveraging this framework, FERAL provides a robust platform for developing complex simulations that require sophisticated Models of Computation and Communication, facilitating efficient and effective simulation model integration and execution.