eosim::core::Model Class Reference
[Modeling ClasesRunning Simulations]

#include <eosim/core/model.hpp>

Collaboration diagram for eosim::core::Model:

Collaboration graph
[legend]
List of all members.

Detailed Description

System Model.

Author:
Sebastián Alaggia
Version:
1.0.1
Date:
2005

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.


Constructor & Destructor Documentation

Model::Model (  ) 

The constructor creates a primitive Model.

Note:
Its recommended that in the constructor of an specific model all attributes are created.

Remember that all entities must be created dynamically, even global entities.

Model::~Model (  )  [virtual]

The destructor of Model.


Member Function Documentation

virtual void eosim::core::Model::init (  )  [pure virtual]

This operation initialize a model.

Note:
In this abstract operation, every model’s attribute (events, distributions, bins and histograms) has to be created (if they aren’t created yet) and registered. Those attributes which are not registered won’t work properly.

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.

Note:
In this abstract operation the programmer has to schedule the firsts entities.

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.

Warning:
The model must not be connected to an experiment.

void Model::registerBEvent ( BEvent bEv  ) 

This operation register bEv in the model.

Note:
If a BEvent is not register to its model, entity will not be scheduled to that event.
Warning:
The model must be connected to an experiment and bEv must be not null.

void Model::registerCEvent ( CEvent cEv  ) 

This operation register cEv in the model.

Note:
If a CEvent is not register into its model, it won’t be executed during the simulation.
Warning:
The model must be connected to an experiment and cEv must be not null.

void Model::registerDist ( dist::Distribution dist  ) 

This operation register dist in the model.

Note:
If a Distribution is not register into its model, it’s seed won’t be changed by the operation Experiment::setSeed.
Warning:
The model must be connected to an experiment and dist must be not null.

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.

Warning:
The model must be connected to an experiment, who must be not null, and there must be a bEvent registered with the name what.

double Model::getSimTime (  ) 

This operation returns the simulation’s actual time.

Warning:
The model must be connected to an experiment.


Generated on Tue Oct 14 16:48:48 2008 for EOSimulator by  doxygen 1.5.2