### The MetaSim Project

#### The background...

The story of this project begins with RTSim, a simulator for complex real-time systems developed at RETIS Lab. Some of the design techniques used in that project were general enough to be re-used in a completely different context: FTRSim, a simulator for financial markets.

It's difficult to find two context that are more different. However, both simulators are based on the discrete event model and in both there were common needs and common ways to approach the problems. So we decided to extract these patterns and put them in a different separate library. In these way we separated a bunch of classes that we can re-use in the future. We built our tools for making new simulators!

MetaSim is an evolving project: many parts of the library can be expanded. For example, it is possible to add new random distributions, new statistical classes, etc. For details of how to contribute to the project, go in the contact info section.

#### Discrete Event Simulation

A system can be viewed as a set of interacting components, each of them has an internal state: the state of the system is a composition of the states of its components (in our system, a component is referred as an entity). In a discrete event simulation, time is discrete and the system can change its state at certain discrete instants called events.

Let's make a simple example: a M/M/1 queue. In this model the status of the system is described by the number of packets present in the queue at any instant. The two significative events are:

• the arrival of a packet in the queue
• the departure of a packet from the queue
In fact, these are the only events that changes the state of the system. In a discrete event model of a M/M/1 queue there is the additional constraint that an event can happen only at discrete instants of time.

A more complex example could be a network of M/M/1 interconnected queues: every queue can be seen as an entity, with its state and its events: the state of the entire system at any instant is a composition of the states of its components. These examples can be found in the tutorial distributed with the library.

The user of a simulator wants to analyze the behavior of a system without actually having the system. So, he makes a model and runs it under different conditions and with different inputs, deterministic or randomly distributed. In a deterministic simulation the user is interested in analyzing the temporal evolution of the system state (trace) under certain conditions. If the input is randomly distributed, the user is interested in obtaining statistics on certain system variables, like average, variance, maximum and minimum value, confidence intervals, etc. For example, in the M/M/1 queue the user may want to compute the average queue lenght.

MetaSim offers a set of classes to help the designer to build discrete event simulations:

• random variables
• statistical processing
• tracing
• debugging facilities

#### Design Patterns and frameworks

The library has been built following the ideas of the Pattern Community. The manifesto of this community is the famous book "Design Patterns and Analysis" by E. Gamma et al.

In particular, our library is a framework of classes that can be used to build simulations. A framework is not only a collection of classes: it is also a "structure" and a "methodology" to implement programs.

to be continued...