This project is read-only.

Simulate

The simulate operator provides capabilities for simulation modelling within Mirelle. It has two different forms - the any and the planner simulation.

Simulate any

The simulate any operator form performs simulation of the classical discrete-event-described system. It works just like a function with two optional parameters: number of processors and maximum queue length (both integer). The returned value is a sim_result structure with it's fields filled. Indeed, for the simulation to perform, the events must be defined beforehand using the emit operator.

The syntax is as follows:
var procs = 1
var queue = 1000
var result = simulate any procs, queue
Both parameters are optional. By default, there is 1 processor and unlimited queue length.

Simulate planner

The planner simulation requires a planner to be defined. The simulate planner operator accepts a method name (static or dynamic) with parameters unspecified, which will be invoked as the wireless planner.

The planner method must have the following signature:
symbol planner(flow[] flows, symbol old_symbol) 
The method must return a new symbol, stacking data from the flows within it's blocks. When a null is returned, the simulation ends, just as when the maximum simulation time has been reached.

The returned value is a filled flow_sim_result structure.

Here's a simple example with the most basic planner and two flows:

type myplanner
{
  static symbol planner(flow[] flows, symbol old)
  {
    var symb = new symbol
    for block in symb.blocks do
    {
      var flow = flow_sim:pick_flow flows
      block.fill flow
    }  
    return symb
  }
}

flow_sim:add new flow flow_type:http, 1, 10, 1
flow_sim:add new flow flow_type:http, 1, 10, 10

flow_sim:time_max = 10000
flow_sim:scale = 500

var result = simulate planner myplanner:planner

var graph = new chart "speed"
for idx => fw in flow_sim:flows
{
  var ser = graph.new_series "flow " + (idx + 1).to_s, 2
  ser.plot fw.wait
} 

Last edited May 13, 2011 at 5:53 PM by impworks, version 1

Comments

No comments yet.