#include <eosim/core/model.hpp>
Collaboration diagram for eosim::core::Model:
This is the parent class of all models. A Model is a model of the system that you are going to simulate. It is a main class in EOSimulator. While Model defines the system, Experiment handles the runs. In order to define an specific model, you have to implement methods to the operations Model::init and Model::doInitialSchedules. You may need to define attributes such as queues, events, distributions, global entities and histograms.
Model is an abstract class which represents a model of the system that we are going to simulate. It contains attributes such as bounded and conditional events, global entities, waiting queues, arrival distributions, service distributions and output data collectors. This class is responsible of:
As we said above, Model is an abstract class. So, to create a specific model, we have to implement a subclass of Model. To do that we must declare every attribute and implement four methods:
Attributes such as events (BEvents or CEvents), distributions (subclases Distribution), containers (typicaly subclases of EntityQueue) and data collector (subclases of Histogram) have to be created, stored and deleted by the model. The library just keeps references to those attributes and doesn’t delete any of them. Besides, these attributes could be created either statically or dynamically. For entities things are a little different (see Entity).
Then, we have to give a method to Model::init. In this operation we must create (if we haven’t done it yet) and register attributes using the register operations defined in Model. The behaviour of the atribute depends on its type.
Finally, Model::doInitialSchedules defines the system initial state. Here you schedule the first entities to the corresponding bounded events. To schedule an entity use Model::schedule with the entity, the time when it is schedule (indicated by a time offset) and the name of the event. The last parameter is very important, it is the key used by the model to find the right event. On return, the entity is inside the calendar, pointing to the BEvent that it was scheduled and with the time when the event is going to happened.
Public Member Functions | |
Model () | |
The constructor creates a primitive Model. | |
virtual | ~Model () |
virtual void | init ()=0 |
This operation initialize a model. | |
virtual void | doInitialSchedules ()=0 |
This operation sets the model's initial state. | |
void | connectToExp (Experiment *exp) |
This operation connects a model to the experiment exp. | |
void | registerBEvent (BEvent *bEv) |
This operation register bEv in the model. | |
void | registerCEvent (CEvent *cEv) |
This operation register cEv in the model. | |
void | registerDist (dist::Distribution *dist) |
This operation register dist in the model. | |
void | schedule (double offset, Entity *who, std::string what) |
This operation schedules who to the BEvent which name is what at the simulation’s actual time plus offset t. | |
double | getSimTime () |
This operation returns the simulation’s actual time. |
Model::Model | ( | ) |
The constructor creates a primitive Model.
Remember that all entities must be created dynamically, even global entities.
Model::~Model | ( | ) | [virtual] |
The destructor of Model.
virtual void eosim::core::Model::init | ( | ) | [pure virtual] |
This operation initialize a model.
This operation is invoked when a model is connected to an experiment.
virtual void eosim::core::Model::doInitialSchedules | ( | ) | [pure virtual] |
This operation sets the model's initial state.
It is invoked when a model is connected to an experiment.
void Model::connectToExp | ( | Experiment * | exp | ) |
This operation connects a model to the experiment exp.
void Model::registerBEvent | ( | BEvent * | bEv | ) |
This operation register bEv in the model.
void Model::registerCEvent | ( | CEvent * | cEv | ) |
This operation register cEv in the model.
void Model::registerDist | ( | dist::Distribution * | dist | ) |
This operation register dist in the model.
void Model::schedule | ( | double | offset, | |
Entity * | who, | |||
std::string | what | |||
) |
This operation schedules who to the BEvent which name is what at the simulation’s actual time plus offset t.
double Model::getSimTime | ( | ) |
This operation returns the simulation’s actual time.