Command Line Interface

A Command Line Interface (CLI) is also provided for running long simulations or parameter fitting:

Simulation

It can be used to simulate a model and save the results. For example, this would simulate the model from the file filename.xml for ten units of time, with 1 unit of time between images, and store the results in results.sme:

./spatial-cli simulate filename.xml 10 1 -o results.sme

The file results.sme can be opened in the GUI to see the simulation results.

An existing simulation can also be continued, for example this would simulate 5 more steps of length 1 and append the results to the existing simulation results in results.sme:

./spatial-cli simulate results.sme 5 1

If the output file is not specified it defaults to overwriting the input file.

Multiple time intervals can be specified as semicolon delimited lists, the same as in the GUI. For example:

./spatial-cli simulate results.sme "5;25;10" "1;2.5;0.1"

If the model already has simulation settings, the positional times and image-intervals arguments can be omitted and the stored settings will be used:

./spatial-cli simulate results.sme --continue-existing-simulation false

Parameter fitting

If parameter optimization has been set up in the model (this can be done in the GUI), the parameter fitting subcommand can be used to run the optimization algorithm. For example, to run 50 iterations of the particle swarm optimization algorithm on the model in filename.xml, using 4 optimization threads with a population of 20 per thread, using the Pixel simulator with a single thread for the simulation, and save the model with the the optimized parameters results in results.sme:

./spatial-cli fit filename.xml -s pixel -t 1 -a PSO -j 4 -p 20 -i 50 -o results.sme

Command line parameters

spatial-cli –help displays the available options and subcommands:

Spatial Model Editor CLI v1.11.0


./cli/spatial-cli [OPTIONS] SUBCOMMAND


OPTIONS:
  -h,     --help              Print this help message and exit
  -v,     --version           Display program version information and exit
  -d,     --dump-config       Dump the default config ini file and exit
  -c,     --config            Read an ini file containing simulation options

SUBCOMMANDS:
  simulate                    Run a spatial simulation
  fit                         Run parameter fitting

spatial-cli simulate –help displays the available options for the simulate subcommand:

Run a spatial simulation


./spatial-cli simulate [OPTIONS] file [times] [image-intervals]


POSITIONALS:
  file TEXT:FILE REQUIRED     The spatial SBML model to simulate
  times TEXT                  The simulation time(s) (in model units of time, separated by ';').
                              Optional if image-intervals is also omitted, in which case model
                              simulation settings are used.
  image-intervals TEXT        The interval(s) between saving images (in model units of time).
                              Optional if times is also omitted, in which case model simulation
                              settings are used.

OPTIONS:
  -h,     --help              Print this help message and exit
  -s,     --simulator ENUM:value in {dune->0,pixel->1} OR {0,1}
                              The simulator to use: dune or pixel
  -t,     --max-threads, --nthreads UINT:NONNEGATIVE
                              The maximum number of CPU threads to use when simulating (0 means
                              unlimited). This sets both DUNE and Pixel thread limits.
          --dune-integrator TEXT
                              DUNE integrator: expliciteuler, impliciteuler, heun,
                              fractionalsteptheta, alexander2, shu3, alexander3, or rungekutta4
          --dune-initial-timestep FLOAT
                              DUNE initial timestep
          --dune-min-timestep FLOAT
                              DUNE minimum timestep
          --dune-max-timestep FLOAT
                              DUNE maximum timestep
          --dune-increase-factor FLOAT
                              DUNE timestep increase factor
          --dune-decrease-factor FLOAT
                              DUNE timestep decrease factor
          --dune-output-vtk-files BOOLEAN
                              DUNE output VTK files (true/false)
          --dune-newton-relative-error FLOAT
                              DUNE Newton relative error
          --dune-newton-absolute-error FLOAT
                              DUNE Newton absolute error
          --dune-linear-solver TEXT
                              DUNE linear solver: bicgstab, cg, restartedgmres, umfpack, or superlu
          --dune-max-threads UINT
                              DUNE max CPU threads (0 means unlimited)
          --pixel-integrator ENUM
                              Pixel integrator: rk101, rk212, rk323, or rk435
          --pixel-max-relative-error FLOAT
                              Pixel max relative local error
          --pixel-max-absolute-error FLOAT
                              Pixel max absolute local error
          --pixel-max-timestep FLOAT
                              Pixel max timestep
          --pixel-enable-multithreading BOOLEAN
                              Enable Pixel multithreading (true/false)
          --pixel-max-threads UINT
                              Pixel max CPU threads (0 means unlimited)
          --pixel-do-cse BOOLEAN
                              Enable Pixel common subexpression elimination (true/false)
          --pixel-opt-level UINT
                              Pixel compiler optimization level (0-3)
  -o,     --output-file TEXT  The output file to write the results to. If not set, then the
                              input file is used.
          --timeout-seconds FLOAT [-1]
                              Simulation timeout in seconds (-1 means no timeout)
          --throw-on-timeout BOOLEAN [1]
                              Whether to treat timeout as an error (true/false)
          --continue-existing-simulation BOOLEAN [1]
                              Whether to continue existing simulation results from the input model
                              (true/false)

spatial-cli fit –help displays the available options for the parameter fitting subcommand:

Run parameter fitting


./spatial-cli fit [OPTIONS] file


POSITIONALS:
  file TEXT:FILE REQUIRED     The spatial SBML model to simulate

OPTIONS:
  -h,     --help              Print this help message and exit
  -s,     --simulator ENUM:value in {dune->0,pixel->1} OR {0,1}
                              The simulator to use: dune or pixel
  -t,     --max-threads, --nthreads UINT:NONNEGATIVE
                              The maximum number of CPU threads to use when simulating (0 means
                              unlimited). This sets both DUNE and Pixel thread limits.
          --dune-integrator TEXT
          --dune-initial-timestep FLOAT
          --dune-min-timestep FLOAT
          --dune-max-timestep FLOAT
          --dune-increase-factor FLOAT
          --dune-decrease-factor FLOAT
          --dune-output-vtk-files BOOLEAN
          --dune-newton-relative-error FLOAT
          --dune-newton-absolute-error FLOAT
          --dune-linear-solver TEXT
          --dune-max-threads UINT
          --pixel-integrator ENUM
          --pixel-max-relative-error FLOAT
          --pixel-max-absolute-error FLOAT
          --pixel-max-timestep FLOAT
          --pixel-enable-multithreading BOOLEAN
          --pixel-max-threads UINT
          --pixel-do-cse BOOLEAN
          --pixel-opt-level UINT
  -o,     --output-file TEXT  The output file to write the results to. If not set, then the
                              input file is used.
  -a,     --algorithm ENUM:value in {ABC->6,AL->12,BOBYQA->9,COBYLA->8,DE->2,GPSO->1,NMS->10,PRAXIS->13,PSO->0,gaco->7,iDE->3,jDE->4,pDE->5,sbplx->11} OR {6,12,9,8,2,1,10,13,0,7,3,4,5,11} [0]
                              The optimization algorithm to use
  -i,     --n-iterations UINT:POSITIVE [20]
                              The number of iterations to run the fitting algorithm
  -p,     --population-per-thread UINT:POSITIVE [20]
                              The population per optimization thread
  -j,     --n-threads UINT:POSITIVE [1]
                              The number of optimization threads

Using a config file

To create an ini file with all options set to their default values, you can use the -d option:

./spatial-cli -d > config.ini

You can then edit this file as desired, and use it with the -c option instead of specifying the options on the command line:

./spatial-cli fit -c config.ini