MyNixOS website logo
Description

A Stochastic Cellular Automaton Engine.

An engine for stochastic cellular automata. It provides a high-level interface to declare a model, which can then be simulated by various backends (Genin et al. (2023) <doi:10.1101/2023.11.08.566206>).

Codecov test coverage R-CMD-check

Chouca: a fast engine for stochastic cellular automata

Stochastic cellular automata are models that are based on a 2D grid of cells, each cell being in one of several discrete states. At each time step, those cells can transition from one state to another with a given probability. This probability typically depends on the neighbors of the cell and the global state of the landscape.

You probably already know Conway's game of life -- a stochastic cellular automaton is the same, except that cell transitions do not always occur when a rule is satisfied, but with a given probability. It typically looks like this:

example SCA

What this package implements

This package is an engine for stochastic cellular automata (SCA), although it can also run deterministic cellular automata. The objective is to provide a high-level, declarative interface to an SCA model, and leave the implementation details to the package.

For example, Kubo's forest model (Kubo, 1996), which describes how gaps created by wind in a forest appear and expand, can be implemented using the following few lines of code:

kubo <- camodel(
  transition(from = "TREE",
             to   = "EMPTY",
             prob = ~ d + delta * q["EMPTY"] ),
  transition(from = "EMPTY",
             to   = "TREE",
             prob = ~ alpha * p["TREE"]),
  parms = list(d = 0.125,
               delta = 0.1,
               alpha = 0.25),
  wrap = TRUE,
  neighbors = 4,
  all_states = c("EMPTY", "TREE")
)

Running the model for 200 iterations on a 100x100 grid is another couple of lines:

initmat <- generate_initmat(kubo, c(TREE = 0.5, EMPTY = 0.5), nrow = 100, nc = 100)
run_camodel(kubo, initmat, times = seq(0, 200))

chouca can display results as they are being simulated, making visual explorations easier:

options <- list(custom_output_fun = landscape_plotter(kubo, fps_cap = 24))

run_camodel(kubo, initmat, times = seq(0, 200), control = options)

Motivation and objectives

Stochastic cellular automata are widely used in ecology to describe the dynamics of organisms over space, and investigate how their interactions may affect the dynamic of the system as a whole. However, implementing those models is often done using ad-hoc R code, which is slow, error-prone, and does not encourage exploring different variations around a single model. chouca provides a high-level interface to such type of models, in order to reduce errors, and spend more time on model design, rather than debugging ugly code.

chouca wants to be user-friendly, yet provide very good performance. Several backend are provided, the main one being in C++. chouca can also emit and compile the required C++ code at runtime for a specific model. This allows making optimizations that would be impossible otherwise, and improves performance typically one or two orders of magnitude.

Here are a few graphs that should help you judge what performance to expect from chouca. These curves represent the average performance across a few models taken from the literature:

Installation

chouca can be installed with the devtools package directly from github:

devtools::install_github("alexgenin/chouca")

Authors and acknowledgements

chouca is mainly developed by Alexandre Génin, but contributions and discussion are of course welcome!

This work has received funding from the European Union’s Horizon 2020 research and innovation programme under the Marie Sklodowska-Curie grant agreement N°896159.

Metadata

Version

0.1.99

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows