mit einem Klick
catcolab-stock-flow
CatColab Stock-and-Flow Diagrams - epidemiological and ecological modeling with stocks (accumulations), flows (rates), and mass-action ODE semantics for SIR models and population dynamics.
Menü
CatColab Stock-and-Flow Diagrams - epidemiological and ecological modeling with stocks (accumulations), flows (rates), and mass-action ODE semantics for SIR models and population dynamics.
Basierend auf der SOC-Berufsklassifikation
Query and explore the 2600: The Hacker Quarterly magazine archive (1984-present) via DuckDB. Provides structured access to 168+ issues covering hacker culture, security, privacy, telephony, and digital rights without loading full content into context.
ACSets (Attributed C-Sets): Algebraic databases with Specter-style bidirectional navigation. Category-theoretic formalism for relational databases.
Attributed C-Sets as algebraic databases. Category-theoretic data structures generalizing graphs and dataframes with Gay.jl color integration.
ACSets (Attributed C-Sets): Algebraic databases with Specter-style bidirectional
Bridge active inference theory with robot control using K-Scale's JAX/MuJoCo stack. Use when connecting predictive coding to locomotion policies, mapping KL divergence minimization to RL training, applying mean field approximation to robotics state estimation, or implementing sim2real as inference about future observations.
Implement affective valence as directional derivative of interoceptive energy landscapes for AI alignment. Use when building alignment-aware RL agents, validating GF(3) conservation in reward signals, training Langevin-based policies, or analyzing fold-change detection signals in POMDP environments.
| name | catcolab-stock-flow |
| description | CatColab Stock-and-Flow Diagrams - epidemiological and ecological modeling with stocks (accumulations), flows (rates), and mass-action ODE semantics for SIR models and population dynamics. |
| version | 1.0.0 |
Trit: +1 (PLUS - generator) Color: Orange (#FF8C00)
Stock-and-Flow diagrams in CatColab model systems with:
This is the foundation for epidemiological models (SIR), ecological models (Lotka-Volterra), and resource dynamics.
┌─────────────────────────────────────────────────────┐
│ STOCK-AND-FLOW DIAGRAM │
├─────────────────────────────────────────────────────┤
│ Stocks (Accumulations): │
│ [S] Susceptible [I] Infected [R] Recovered │
│ │
│ Flows (Rates): │
│ infection: S → I │
│ recovery: I → R │
│ │
│ Links (Influences): │
│ I ──link──► infection (infected influence rate) │
│ │
│ Diagram: │
│ ┌───┐ infection ┌───┐ recovery ┌───┐ │
│ │ S │ ═══════════► │ I │ ═══════════► │ R │ │
│ └───┘ └───┘ └───┘ │
│ ▲ │ │
│ └────── link ─────┘ │
└─────────────────────────────────────────────────────┘
// Stock-Flow double theory
pub fn th_stock_flow() -> DiscreteDblTheory {
let mut cat = FpCategory::new();
// Object type
cat.add_ob_generator(name("Stock"));
// Morphism types
cat.add_mor_generator(name("Flow"), name("Stock"), name("Stock"));
cat.add_mor_generator(name("Link"), name("Stock"), name("Stock"));
cat.into()
}
CatColab generates mass-action ODEs from stock-flow diagrams:
For flow f: A → B influenced by links from stocks {Sᵢ}:
rate(f) = k_f · A · ∏ᵢ Sᵢ
dA/dt = -rate(f) + (inflows to A)
dB/dt = +rate(f) + (other flows)
Stocks: S, I, R
Flows: infection (S→I), recovery (I→R)
Links: I influences infection
Generated ODEs:
dS/dt = -β·S·I
dI/dt = +β·S·I - γ·I
dR/dt = +γ·I
Where β = infection rate, γ = recovery rate
{
"type": "ObDecl",
"name": "Susceptible",
"theory_type": "Stock",
"description": "population not yet infected"
}
{
"type": "MorDecl",
"name": "infection",
"dom": "Susceptible",
"cod": "Infected",
"theory_type": "Flow",
"description": "rate at which susceptibles become infected"
}
{
"type": "MorDecl",
"name": "contact_influence",
"dom": "Infected",
"cod": "Susceptible",
"theory_type": "Link",
"description": "infected population influences infection rate"
}
Stocks: S (Susceptible), I (Infected), R (Recovered)
Flows:
infection: S → I
recovery: I → R
Links:
I → infection (more infected = faster spread)
Parameters:
β (infection rate): 0.3
γ (recovery rate): 0.1
R₀ = β/γ = 3.0 (epidemic threshold > 1)
Stocks: S, E (Exposed), I, R
Flows:
exposure: S → E
onset: E → I
recovery: I → R
Links:
I → exposure (infected spread disease)
Addition: Latency period before becoming infectious
Stocks: Rabbits, Foxes
Flows:
rabbit_birth: ∅ → Rabbits
rabbit_death: Rabbits → ∅
predation: Rabbits → Foxes
fox_death: Foxes → ∅
Links:
Rabbits → rabbit_birth (reproduction)
Foxes → predation (hunting)
Foxes → rabbit_death (hunting pressure)
ODEs:
dR/dt = αR - βRF
dF/dt = δRF - γF
Stocks: Resource, Capital, Population
Flows:
extraction: Resource → Capital
investment: Capital → Capital
consumption: Capital → ∅
birth: ∅ → Population
death: Population → ∅
Links:
Population → extraction
Capital → birth
Resource → extraction (scarcity effect)
CatColab provides for stock-flow models:
Stock-flow diagrams compose via stratification:
# Base SIR model
sir = @acset StockFlow begin
Stock = [:S, :I, :R]
Flow = [(:S, :I), (:I, :R)]
end
# Age-stratified version (young/old)
age_strata = @acset Strata begin
Stratum = [:Young, :Old]
end
# Compose: SIR × Age = 6 stocks (S_young, S_old, ...)
stratified_sir = stratify(sir, age_strata)
catcolab-regulatory-networks (-1) ⊗ catcolab-causal-loop (0) ⊗ catcolab-stock-flow (+1) = 0 ✓
catcolab-ologs (-1) ⊗ topos-catcolab (0) ⊗ catcolab-stock-flow (+1) = 0 ✓
# Create stock-flow model
just catcolab-new primitive-stock-flow "sir-model"
# Generate mass-action ODEs
just catcolab-analyze sir-model --odes
# Simulate epidemic
just catcolab-simulate sir-model --params "β=0.3,γ=0.1" --time 100
# Stratify by age
just catcolab-stratify sir-model age-strata
# Export to AlgebraicJulia
just catcolab-export sir-model --format=julia
using AlgebraicPetri
using Catlab
# Load CatColab model
model = load_stockflow("sir-model.json")
# Convert to Petri net
petri = stockflow_to_petri(model)
# Simulate with DifferentialEquations.jl
using OrdinaryDiffEq
u0 = [990.0, 10.0, 0.0] # S, I, R
prob = ODEProblem(vectorfield(petri), u0, (0.0, 100.0))
sol = solve(prob, Tsit5())
Skill Name: catcolab-stock-flow Type: Epidemiology / Population Dynamics Trit: +1 (PLUS) GF(3): Conserved via triadic composition