Cain is written in <a href="http://www.python.org/">Python</a> and uses the
<a href="http://www.wxpython.org/">wxPython</a> GUI toolkit.
For plotting simulation results, it uses
<a href="http://matplotlib.sourceforge.net/">matplotlib</a> and
To simplify mathematical expressions, it uses
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 <a href="UserLauncher.htm">launcher</a> 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 <a href="https://bitbucket.org/seanmauch/cain/wiki/Home">source
code</a> for Cain, both Python application code and C++ solver
code is hosted on <a href="https://bitbucket.org/">Bitbucket</a>.
(Most of the C++ source is extracted from
which is a scientific computing C++ template library.)
Follow the instructions on the
<a href="https://bitbucket.org/seanmauch/cain/wiki/Home">Cain wiki</a>
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 <tt>seanmauch-cain-0cdb9c4c1739.zip</tt>. First uncompress
the file, unless your browser does that for you.<br>
Then you can rename the directory to a more convenient name.<br>
<tt>mv seanmauch-cain-0cdb9c4c1739 cain</tt>
To work with the source code, you will need Python and a suitable
C++ compiler. Read the <a href="Installation.htm">installation
instructions</a> for your operating system for details.
The easiest way to get Python and the necessary packages is to
<a href="http://www.enthought.com/products/epd.php">Enthought Python
Distribution</a>. (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.<br>
This simply calls the makefile in the <tt>src/solvers</tt> directory.
For Windows users, open a shell, go to the solvers directory, and run
the <tt>msvs.py</tt> script.<br>
The Python source code is split into the four top-level directories:
<tt>gui</tt>, <tt>io</tt>, <tt>simulation</tt>, and <tt>state</tt>.
The script <tt>Cain.py</tt>
launches the application. Thus you can launch Cain with the shell command
<tt>python Cain.py</tt>. The C++ source code packages are in
<tt>src</tt>. If you want to have a look at the source code, start
with the <tt>stochastic</tt> package. The random number generators
are implemented in <tt>numerical/random</tt>.
The source code for the command-line solvers is in
<tt>src/solvers</tt>. The compiled executables are placed in
the <tt>solvers</tt> directory.
<b>Microsoft Windows Development Environment.</b><br>
First get <a href="http://www.mingw.org/wiki/Getting_Started">MinGW</a>
by running the MinGW-5.1.6 installer. Then get
<a href="http://www.mingw.org/wiki/MSYS">MSYS</a>. Install MSYS 1.0.11,
MSYS DTK 1.0.11, and set the environment variable HOME to
c:\msys\1.0\home\user_name. Make a .ssh directory in your home
directory and place your public and private SSH keys there. Then you
can use the shell commands "ssh-agent $SHELL" followed by
"ssh-add" to start a shell with SSH authentication. Next
install subversion by running the Setup-Subversion-1.6.6.msi
installer, which will add the svn executable to your path. If you
don't already have a text editor, you can download