python:simplot

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. The latter are called *response variables*.
Each design variable has a finite set of distinct values which can be used, values of response variables can be continuous in nature (that is, of type real).

A simulation can be considered to be a function. A value for each design variable is put into the simulation-function, and after a while, the function delivers values for each of the response variables. Note that the simulation-function is not always a true function, for example, the values of response variables may vary slightly with each simulation if stochastics are used.

Insight in the behavior is often obtained by relating (combinations of) values of design variables to values of output variables. Normally, this is done by plotting the values of the variables against each other after doing 'enough' simulations.
Currently, `Simplot`

aims to assist in the latter process (since the program is still in the experimental stages, it may drift to other parts of the simulation study process in the future).

The `Simplot`

program assumes that the results of a single simulation is put on a single line of the form

<value-of-all-design-variables> ':' <value-of-all-response-variables>

where a value of a variable is written as

<name-of-the-variable>'='<value-of-the-variable>

(that is, no white space exists in the variable value). Different variables are seperated by white space.

For example, assume that a simulation takes values for integer design variables `p`

and `q`

, and computes the value of response variables `u`

and `v`

. After 9 simulations, the file `simplotdata`

with simulation results looks like

p=0 q=0 : u=0.0 v=2 p=0 q=1 : u=0.5 v=1 p=0 q=2 : u=1.0 v=2 p=1 q=0 : u=1.0 v=1 p=1 q=1 : u=1.5 v=0 p=1 q=2 : u=2.0 v=1 p=2 q=0 : u=2.0 v=2 p=2 q=1 : u=2.5 v=1 p=2 q=2 : u=3.0 v=2

The program can show which variables (and which values) are used by

simplot.py list -f simplotdata

This gives the following output:

Design variables: q 0, 1, 2 p 0, 1, 2 Response variables: u v

which is not very surprising of course, but for larger sets of variabls and data values, it may be useful.

The more useful feature of the program is that it can plot values of variables against each other.
To plot `p`

against `u`

with `q=1`

, you type

simplot.py plot -g -f simplotdata --x=p --y=u q=1

which results in a `Gnuplot`

window with a straight line as expected. When you are finished looking at the graph, press Enter in the terminal window where you started `Simplot`

. (For those of you without a nearby `Gnuplot`

, the results looks like pu.svg or pu_png.)
If you leave out the `-g`

, the program outputs the Gnuplot script used to create the graph. You can save it in a file, and generate output in a different format (a `Gnuplot`

manual is available at http://gnuplot.sourceforge.net), for example appropiate for including in a report.

If you want to have the value of `p`

against `v`

for all values of `q`

, enter

simplot.py plot -g -f simplotdata --x=p --y=v

(The Y axis should display the value of `v`

, so the `–y`

option must be set to `v`

rather than `u`

. Also, you do not want to restrict the value of `q`

, so no need to specify `q=1`

.)
This gives you a graph with three lines, except that the `q=0`

line and the `q=2`

line are on top of each other, so you see only one of them. (If you don't have `Gnuplot`

, the graph looks like pv_all.svg or pv_all_png.)

Finally, you can also have 3D graphs, by specifying a Z axis, like

simplot.py plot -g -f simplotdata --x=p --y=q --z=u

(The result looks like pqu.svg or pqu_png.)
Since you use all design variables, you get only one surface.
(When you run it without `-g`

, save the result, and manually start `Gnuplot`

, you can interactively rotate the graph.)

You can download the program from here.

python/simplot.txt · Last modified: Tuesday, 22 August 2006 : 09:11:04 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International