Skip to content

m-onz/plasmodium

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plasmodium

Graph optimisation inspired by Physarum polycephalum. A process-per-cell simulation of slime-mould biology on the BEAM, with a small Elixir façade over a raw-Erlang core.

You give it a graph (static, or grown on demand via a discovery callback) and food/repellent signals. It grows an organism that reinforces the high-conductance subnetwork — the answer to a graph-shortest-path / flow-optimisation problem expressed without a central solver.

tokyo

Installation

Add to mix.exs:

def deps do
  [
    {:plasmodium, "~> 0.1"}
  ]
end

Usage

world =
  Plasmodium.start()
  |> Plasmodium.add_chain(~w(a b c d e))
  |> Plasmodium.set_food("e", 2.0)
  |> Plasmodium.grow(from: "a")
  |> Plasmodium.wait(5_000)

Plasmodium.network(world)
Plasmodium.stop(world)

Or, as a one-shot script:

%{network: edges, stats: _} =
  Plasmodium.run!(
    chain: ~w(a b c d e),
    food: %{"e" => 2.0},
    from: "a",
    for: 5_000
  )

For graphs that aren't known up front (web crawl, code analysis, fuzzing), implement Plasmodium.Discover and pass it via start(discover: ...). The organism grows the graph lazily as growth fronts reach into it.

Modes

grow/2 runs in one of two modes:

  • :fast (default) — Tero-grade tube adaptation. Disables Kuramoto coupling, flow EMA smoothing, the Marbach 3-second integration window, and Kramar–Alim dilatability memory. Use for single-pass graph optimisation; converges in seconds.
  • :biology — full biophysical model. Use for long-running scans, mid-run signal injection, or biophysical experiments where multi-timescale robustness against transient noise matters.

Rate-style options (1/s)

All decay and production rates use continuous-time units (per second) so timescales are invariant under changes to tick_ms. The relevant options:

  • signal_decay_rate (cytoplasm, default 0.25) — C(t) = C0 · exp(-λ·t). Replaces the legacy per-tick signal_decay.
  • food_signal_production_rate (cytoplasm, default 0.75) — signal produced per second per unit local food.
  • dilatability_decay_rate (wall, default 0.025) — relaxation rate of Kramar–Alim tube softness back toward 1.0. Replaces the legacy per-tick dilatability_decay_per_tick.

The old per-tick option names are still accepted for back-compat but are interpreted as rates (per second). Callers that relied on the per-tick interpretation must rescale.

What it's good for

  • Finding the high-conductance subnetwork of an evolving graph.
  • Anything shaped like "follow gradients, exploit dense paths, abandon dead ends" — web crawl, dependency analysis, fuzzing reachability.
  • Problems where the graph is too large to enumerate up front but small enough that thousands of processes per node is feasible.

What it's not for

  • Tight numerical work — this is biology, not a solver. For exact shortest paths, use a real graph library.
  • Single-machine graphs above a few hundred thousand nodes. The process count grows with reachable nodes.
  • Anywhere you need deterministic results. The dynamics are stochastic by design.

Architecture

The biology runs in raw Erlang processes (src/pl_*.erl) with hand-rolled receive loops and neighbour-only message passing — no central solver, no global scheduler. Six process types: pl_cytoplasm, pl_wall, pl_growth_front, pl_sheet, pl_nucleus, pl_location. The world registry (pl_world) is a gen_server for :sys introspection.

For pid-level primitives used in research code and biology tests, see Plasmodium.Internals (@moduledoc false).

Background

Famously in 2010, when oat flakes were placed where the cities around Tokyo go, a slime mould grew a transport network between them that closely resembled the actual Tokyo subway. Plasmodium implements the underlying biophysics (Tero 2010 tube adaptation, Alim 2017 advection, Kramar–Alim 2021 dilatability) on the BEAM's process model.

License

MIT.

About

Slime mould algorithm inspired by physarum polycephalum

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors