<title>Command Line Solvers</title>
<h1>Command Line Solvers</h1>
For most methods, Cain uses command line executables to carry out
the simulations. The executables are in the <tt>solvers</tt> directory.
It is easy to add a new simulation method to Cain if it is similar to
one of the built-in methods. Just write a
program that reads the same <a href="DeveloperFile.htm">input format</a>
and generates the same output
format as one of the other solvers. You can write your program in any
language and use any software or hardware resources that you have on
Place your program in the <tt>solvers</tt>
directory. Then edit the data in the file
Note that the Cain solvers are serial.
The application utilizes concurrency by running multiple
instances of a solver. If your solver has multiple threads, then you
should select one process in the launcher panel when using your
solver, so that only one instance of the solver is run.
If you would like to add a solver to the Cain distribution, contact
me at <img src="seanEmail.png">. Your work will be noted in
the <a href="Simulation.htm">Simulation Methods</a> chapter of this
documentation. I will add links to any of your relevant papers and web
sites. The contributed code will be distributed under the three-clause
BSD <a href="License.htm">license</a>.
While there is great flexibility in developing personal extensions to Cain,
contributed solvers should roughly match the built-in solvers. The
best way to proceed is to use an existing solver as a template. You
will want to use the random number package in
<tt>src/numerical/random</tt>. The solvers take an initial state of
the Mersenne Twister as input and return the final state.
Note that most of the built-in solvers can either be used with
mass action kinetics or custom propensities (i.e. the propensity
functions for the reactions may be any user-defined function).
To accomplish this, the C++ solver classes take the propensities
functor as a template parameter. For mass action kinetics, the
propensity functor will be either <tt>PropensitiesSingle</tt>
or <tt>PropensitiesAll</tt>, which are defined in
<tt>src/stochastic/Propensities.h</tt>. For custom propensities,
the propensity functor is the <tt>Propensities</tt> class,
defined in <tt>src/solvers/Propensities.h</tt>. When a solver
with custom propensities is run, the application generates
appropriate C++ code, compiles the solver, and then launches it.
When writing your solver, it may be easier to initially support only
mass-action kinetics. Once that is working, you may add the
custom propensities capability.
When developing your solver, you can either put it in the
<tt>src/solvers</tt> directory and use the makefile there to
compile it, or you may place it in an arbitrary directory.
If you choose the latter option. Copy the contents of <tt>src</tt>
to a convenient location and add it to your include path.
Note that all of the packages in <tt>src</tt> are template
class libraries. That is, they are just header files. To
use a package, simply include the appropriate header.
There is no need to compile any libraries and link with