User Tools

Site Tools


python:runner

Runner

Simulation studies aim to provide insight in the behavior of the system being simulated. This is done by subjecting the (model of the) system to various different settings of design variables (for example different arrival patterns, or different product mixes), and observing the performance of the system, for example mean throughput. To obtain a good idea of system behaviour, the performance is often tested for many parameter settings. Calling the program for each possible combination of parameter settings is often undesirable. Therefore, this script can be used.

How runner.py should be used is explained in the file itself. An example is included.

Python code + example

### Author: A.A.A. Kock
### email: a.a.a.kock@tue.nl
### runner.py
### Execute simulation model in myprog.chi. The model name is "Mod1"
### Suppose the program has input variables x,y,z:

import os

# Define the parameters and their domain for the simulation test bed
xs = [0,1,2,3]
ys = [0.1,0.2,0.3]
zs = [0.5,1.0,1.5]

# execute the program for each combination of parameters:

for x in xs:
   for y in ys:
      for z in zs:
         pars1 = str(x)+' '+str(y)+' '+str(z)
         pars2 = 'x'+str(x)+'y'+str(y)+'z'+str(z)
         os.system('./myprog Mod1 '+pars1+' >output'+pars2+'.txt')
         
# this file may be used under linux by giving the command "python runner.py"

## As an example, consider a problem with variables: length, utilization, 
## squared coefficient of variation and buffersize:
#
#lens = [2,5,10]
#us   = ['06','09']
#c2s  = ['01','10','20']
#bufs = [0,1,3]
#
## Note that the parameters us and c2s are given as strings since 
## they are implemented in the model as strings
#for l in lens:
#   for u in us:
#     for c in c2s:
#       for b in bufs:\
#         pars1 = str(l)+' '+str(b)+' '+str(c)+' '+str(u)
#         pars2 = 'l'+str(l)+'b'+str(b)+'c'+str(c)+'u'+str(u)
#         os.system('./myprog Mod1 '+pars+' >> output'+pars+'.txt')

Obtaining the program

You can download the program here

python/runner.txt · Last modified: Thursday, 19 October 2006 : 16:38:22 (external edit)