Developer's Guide

Cain is written in Python and uses the wxPython GUI toolkit. For plotting simulation results, it uses matplotlib and numpy. To simplify mathematical expressions, it uses SymPy. Cain utilizes command line executables to perform the simulations. These executables read a description of the problem (model, method, and number of trajectories) from stdin and write the trajectories to stdout. Cain launches the executables; it sends the input and captures the output with pipes. When launching a job, the user select the number of processes to use. Cain launches this number of executables. It asks the pool of solvers to each generate trajectories a specified number at a time until the desired number has been collected. (See the documentation for the granularity slider in the launcher panel for details.) This allows the user to stop or abort a running simulation and store the trajectories that have been generated so far.

The source code for Cain, both Python application code and C++ solver code is hosted on Bitbucket. (Most of the C++ source is extracted from STLib, which is a scientific computing C++ template library.) Follow the instructions on the Cain wiki to download the source code. If you download a compressed archive of a development snapshot, you will get a file name that records the Mercurial version, for example seanmauch-cain-0cdb9c4c1739.zip. First uncompress the file, unless your browser does that for you.
unzip seanmauch-cain-0cdb9c4c1739.zip
Then you can rename the directory to a more convenient name.
mv seanmauch-cain-0cdb9c4c1739 cain

To work with the source code, you will need Python and a suitable C++ compiler. Read the installation instructions for your operating system for details. The easiest way to get Python and the necessary packages is to install the Enthought Python Distribution. (Note for Microsoft Windows users: The installation instructions don't mention Python because a suitable version of Python is packaged with the Windows distribution. However, to work with the source code you will need to install Python.)

Before running the application, you will need to build the solvers. (Technically, you can run the GUI application without building the solvers, you just can't run any simulations that use the C++ solvers.) In the top-level directory, run the makefile.
cd cain
make
This simply calls the makefile in the src/solvers directory. For Windows users, open a shell, go to the solvers directory, and run the msvs.py script.
cd cain\src\solvers
python msvs.py

The Python source code is split into the four top-level directories: gui, io, simulation, and state. The script Cain.py launches the application. Thus you can launch Cain with the shell command python Cain.py. The C++ source code packages are in src. If you want to have a look at the source code, start with the stochastic package. The random number generators are implemented in numerical/random. The source code for the command-line solvers is in src/solvers. The compiled executables are placed in the solvers directory.