This project is read-only.

Emit

The emit keyword supports simulation modelling in Mirelle. It's a declarative syntactic construction that defines a new event emitter and sets it's properties. It has quite a few properties which are set by keywords with , every , limit and until . Here's an example of the fully-defined event emitter:

emit action every 10 with distr:normal limit 100 until sim:time < 500 

Action

The event is defined by a method that is invoked when the event occurs during simulation. You can specify the method name and optional parameters right after the emit keyword:
type test
{
  static void handler: int count
  {
    println "handler! ", count
  }
}

emit test:handler 1337 every 10 limit 100 

Please note that the events will start firing only when you call the simulate operator.

Closuring

The emitter action closures local variables. It means, you can call do it like:

var value = 1337
emit test:handler value every 10 limit 100 

However, you cannot reference local methods or fields when defining the emitter in a methods, and neither can you use the @ pointer.
You can, however, save it to a local variable and use it instead!

Time lapse

The events occur with a given time lapse between them. You can set the time lapse with either every or with keywords, or both!

The every keyword sets a constant time lapse and requires a float or an int. If you write:
emit test:handler 123 every 10 

you may be sure that the event will occur every 10 seconds (or whichever units of time measuring are more appropriate for your project).

The with keyword defines a probability distribution and requires an object of the Distr type. It provides randomization for time lapses.
The exact properties of the time lapse generated with the with keyword depend on the properties of the distribution.

If the two keywords are present at the same time, their results will be added.

Ending condition

The event emitter can emit an unlimited number of events, but in this case the simulation will never finish. To avoid this undesired situation, you must specify an ending condition which stops new events from being emitted when it is met. The condition may be set with either limit , until or both keywords at the same time.

The limit keyword sets the maximum number of events emitted and requires an int. When the internal counter equals this value, the emitter will stop.

The until keyword expects a boolean expression and will stop the emitter when it returns true. It is also closuring the local variables, just like the emitter action,

Emit once

It's possible to set the event to fire just once at a specific moment of system time - for example, to make changes to the system and see how it adapts to it. The following syntax is suggested:
emit test:handler once at 100

The code above is a more readable and a bit shorter equivalent to:
emit test:handler every 100 limit 1 

Related pages: Simulation Modelling, Distr, Sim

Last edited May 15, 2011 at 7:13 PM by impworks, version 4

Comments

No comments yet.