Package Python

pyvle, ''Python-Package for VLE

= Description =

PyVLE is a Python package for using VLE framework into Python. It provides functionnalities such as loading vpz files, modifying conditions values of models, simulating vle models and recovering simulation results. It provides other functionnalities regarding the experiment such as modifying duration or seed, obtaining informations on models and views.

PyVLE is one component of a generic solution for developping web applications for VLE framework.

= Usage =

The remaining of this section is based on PyVLE-1.0, the version of PyVLE for VLE-1.0.

For download and installation instructions of vle1.0 and pyvle1.0, go to http://www.vle-project.org/wiki/VLE-1.0

First use
Once VLE and PyVLE are installed, you can launch python and import pyvle. or

The package is mostly based on a Python class Vle. In order to know what functions are available into this package.

First simulation
In this first example:
 * a vpz file is loaded,
 * initial conditions are modified
 * simulation is launched

Outputs are not recovered since the output plugin of the view is not storage.

Here is a Python script.

Notes: But this use is deprecated.
 * this example requires that the VLE package 'glue' is installed.
 * outputs are not recovered since the output plugin of the view is not storage.
 * One can use the global mode of VLE to load a vpz, if it is not part of package.

Recover results
It can be usefull to recover the results of a simulation. To do this, the output plugin of views of the vpz (or at least the view that is expected) should be set to 'storage'. Call to function 'run' will return dictionaries (one per view) odf results.

Here is an example:

To access to the ith value of observables 'obs' into the view 'view', the syntax to use is result['view']['obs'][i]:
 * 'view' the name of the view
 * 'obs' the path to the model concatenated with the port name. For example if the top model, called 'C1' is a coupled model containing the atomic model 'C2' which is observed through the observable port 'p', so obs = 'C1:C2.p'
 * 'i' index of the matrix. In a view configured as a timed-view, i represents the time step value.

Simulation of experiment plans
Examples above show how to launch one simulation. Nevertheless it is possible to launch a bag of simulations with one call of command

In the case only one simulation is required, method 'run' can be used. In the other case, methods 'runManager' or 'runManagerMatrix' are available to simulate one bag of simulations.

For one simulation (see above for interpreting results):

For a bag of simulations, results is more complex since they are as many view dictionaries as couples replica, combination.

One can find the connection between 'combinaison_index' and the initial conditions values it corresponds to.

Web applications
PyVLE can be used for developping web applications, see frameworks Web Python.

The package Pylons is the base of a generic solutions for developping web application for VLE : (in french) vle-web.

Here is a simple example for cretaing a web application with Pylons : (in french) création d'une application Web

= References =

http://www.python.org/