eosim::core::Model                    EoSimulator Programmer's Manual

 

NAME

      Model: System Model

 

SYNOPSIS

      #include <eosim/core/model.hpp>

 

      namespace eosim {

      namespace core {

 

            class Model {

            public:

Model();

virtual ~Model();

virtual void init () = 0;

virtual void doInitialSchedules () = 0;

void connectToExp (Experiment *exp_);

void registerBEvent (BEvent* bEv_);

void registerCEvent (CEvent* cEv_);

void registerDist (dist::Distribution* dist_);

void registerHistogram (statics::Histogram* hist_);

void schedule (double offset_, Entity* who_, std::string what_);

double getSimTime();

            };

 

      }

      }

 

DESCRIPTION

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 init and doInitialSchedules. You may need to define attributes such as queues, events, distributions, global entities and histograms.

EoSimulator support discrete event simulation models using event scheduling world view with even method or three phase approach.

 

CLASS OPERATIONS

Model():

      The constructor creates a primitive Model. 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():

      The destructor of Model.

     

void init ():

            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.

           

void doInitialSchedules ():

            In this abstract operation the programmer has to schedule the firsts entities. It is invoked when a model is connected to an experiment.

     

void connectToExp (Experiment *exp_):

            This operation connects a model to the experiment exp_. If the model is already connected, the simulation aborts immediately displaying an error message.

     

void registerBEvent (BEvent* bEv_):

            This operation register bEv_ in the model. If a BEvent is not register to its model, entity will not be scheduled to that event. If the model is not connected to an experiment or bEv_ is null, the simulation aborts immediately displaying an error message.

     

void registerCEvent (CEvent* cEv_):

            This operation register cEv_ in the model. If a CEvent is not register into its model, it won’t be executed during the simulation. If the model is not connected to an experiment or cEv_ is null, the simulation aborts immediately displaying an error message.

 

void registerDist (dist::Distribution* dist_):

            This operation register dist_ in the model. If a Distribution is not register into its model, it’s seed won’t be changed by the operation Experiment::setSeed. If the model is not connected to an experiment or dist_ is null, the simulation aborts immediately displaying an error message.

 

void registerHistogram (statics::Histogram* hist_):

            This operation register hist_ in the model. If an Histogram is not register into a model, data will not be logged in it during the simulation. If the model is not connected to an experiment or hist_ is null, the simulation aborts immediately displaying an error message.

 

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. If there isn’t any BEvent with name what_ or the model is not connected to an experiment or offset_ is negative, the simulation aborts immediately displaying an error message.

 

double getSimTime():

            This operation returns the simulation’s actual time. If the model is not connected to an experiment, the simulation aborts immediately displaying an error message.

     

 

SEE ALSO

eosim::core::BEvent

eosim::core::CEvent

eosim::core::Entity

eosim::core::Experiment

eosim::dist::Distribution

eosim::statics::Histogram

eosim::utils::BEventMap

eosim::utils::EntityQueue