Classes | Public Member Functions

adevs::Simulator< X > Class Template Reference

#include <adevs_simulator.h>

Inheritance diagram for adevs::Simulator< X >:
adevs::AbstractSimulator< X >

List of all members.

Classes

struct  bottom_to_top_depth_compare
struct  top_to_bottom_depth_compare

Public Member Functions

 Simulator (Devs< X > *model)
double nextEventTime ()
void execNextEvent ()
 Execute the simulation cycle at time nextEventTime().
void execUntil (double tend)
 Execute until nextEventTime() > tend.
void computeNextOutput ()
void computeNextState (Bag< Event< X > > &input, double t)
 ~Simulator ()
void addModel (Atomic< X > *model)
 Simulator (LogicalProcess< X > *lp)

Detailed Description

template<class X>
class adevs::Simulator< X >

This Simulator class implements the DEVS simulation algorithm. Its methods throw adevs::exception objects if any of the DEVS model constraints are violated (i.e., a negative time advance or a model attempting to send an input directly to itself).


Constructor & Destructor Documentation

template<class X>
adevs::Simulator< X >::Simulator ( Devs< X > *  model  )  [inline]

Create a simulator for a model. The simulator constructor will fail and throw an adevs::exception if the time advance of any component atomic model is less than zero.

Parameters:
model The model to simulate
template<class X >
adevs::Simulator< X >::~Simulator (  ) 

Deletes the simulator, but leaves the model intact. The model must exist when the simulator is deleted. Delete the model only after the Simulator is deleted.

References adevs::Bag< T >::begin(), and adevs::Bag< T >::end().

template<class X>
adevs::Simulator< X >::Simulator ( LogicalProcess< X > *  lp  )  [inline]

Create a simulator that will be used by an LP as part of a parallel simulation. This method is used by the parallel simulator.


Member Function Documentation

template<class X>
void adevs::Simulator< X >::addModel ( Atomic< X > *  model  )  [inline]

Assign a model to the simulator. This has the same effect as passing the model to the constructor.

template<class X >
void adevs::Simulator< X >::computeNextOutput (  ) 

Compute the output values of the imminent component models if these values have not already been computed. This will notify registered EventListeners as the outputs are produced.

References adevs::Bag< T >::begin(), adevs::Bag< T >::empty(), adevs::Bag< T >::end(), adevs::Devs< X >::getParent(), and adevs::Atomic< X >::output_func().

Referenced by adevs::Simulator< X >::computeNextState(), adevs::Simulator< InternalType >::execNextEvent(), and adevs::ModelWrapper< ExternalType, InternalType >::output_func().

template<class X>
void adevs::Simulator< X >::computeNextState ( Bag< Event< X > > &  input,
double  t 
)

Apply the bag of inputs at time t and then compute the next model states. Requires that lastEventTime() <= t <= nextEventTime(). This, in effect, implements the state transition function of the resultant model.

Parameters:
input A bag of (input target,value) pairs
t The time at which the input takes effect

Compute model transitions and build up the prev (pre-transition) and next (post-transition) component sets. These sets are built up from only the models that have the model_transition function evaluated.

The model adds are processed first. This is done so that, if any of the added models are components something that was removed at a higher level, then the models will not have been deleted when trying to schedule them.

If this model has children, then remove them from the deletion set. This will avoid double delete problems.

References adevs::Bag< T >::begin(), adevs::Bag< T >::clear(), adevs::Simulator< X >::computeNextOutput(), adevs::Bag< T >::empty(), adevs::Bag< T >::end(), adevs::Devs< X >::getParent(), adevs::Devs< X >::model_transition(), and adevs::Devs< X >::typeIsNetwork().

Referenced by adevs::ModelWrapper< ExternalType, InternalType >::delta_conf(), adevs::ModelWrapper< ExternalType, InternalType >::delta_ext(), and adevs::Simulator< InternalType >::execNextEvent().

template<class X>
double adevs::Simulator< X >::nextEventTime (  )  [inline, virtual]

The documentation for this class was generated from the following file: