Logistic Growth

A logistic growth simulation of population increase with saturation.

Level:Beginner

populationcapacitynonlinear-dynamicsreinforcing-loop

  • Stocks:population
  • Flows:growth
  • Feedback Loops:reinforcing adoption, saturation constraint
  • Probes:population, growth

Dynamic Behavior Patterns

Explore common system behaviors: exponential growth, goal-seeking decay, overshoot-and-collapse, and S-curve saturation.

Explore Dynamic Behavior Patterns

System Archetypes

Learn recurring structural patterns like Limits to Growth, Fixes That Fail, and Tragedy of the Commons, plus high-leverage interventions.

Explore System Archetypes
simulation.py

Watching a population grow logistically

This classic model starts with a small population that grows almost exponentially. Growth then slows as the number of individuals nudges up against the carrying capacity of the environment.


from tys import probe, progress

Simulate logistic population growth.

def simulate(cfg: dict):

    import simpy
    env = simpy.Environment()

    population = cfg["initial_pop"]
    r = cfg["growth_rate"]
    K = cfg["carrying_capacity"]
    steps = cfg["steps"]

    done = env.event()

Evolve the population using the logistic equation.

    def run():
        nonlocal population
        for t in range(steps):
            growth = r * population * (1 - population / K)
            population += growth
            probe("population", env.now, population)
            probe("growth", env.now, growth)
            progress(int(100 * (t + 1) / steps))
            yield env.timeout(1)
        done.succeed({"final_population": population})

    env.process(run())
    env.run(until=done)
    return done.value


def requirements():
    return {
        "builtin": ["micropip", "pyyaml"],
        "external": ["simpy==4.1.1"],
    }
Default.yaml
initial_pop: 10
growth_rate: 0.2
carrying_capacity: 100
steps: 40
Charts (Default)

population

population chartCSV
Samples40 @ 0.00–39.00
Valuesmin 11.80, mean 71.73, median 86.67, max 99.80, σ 30.45

growth

growth chartCSV
Samples40 @ 0.00–39.00
Valuesmin 0.05, mean 2.24, median 2.10, max 4.99, σ 1.76
Final Results (Default)
MetricValue
final_population99.80
FAQ
When does growth slow down?
The logistic equation multiplies r by population*(1 - population/K), so as population nears K the growth term declines.
How is the carrying capacity used?
It sets the upper limit in the logistic term so population never exceeds K.
Which probes are charted?
Both population and instantaneous growth are emitted each step for plotting.