Stock and flow diagrams are widely used in epidemiology to model the dynamics of populations. Although tools already exist for building these diagrams and simulating the systems they describe, we have created a new package called StockFlow, part of the AlgebraicJulia ecosystem, which uses ideas from category theory to overcome notable limitations of existing software. Compositionality is provided by the theory of decorated cospans: stock and flow diagrams can be composed to form larger ones in an intuitive way formalized by the operad of undirected wiring diagrams. Our approach also cleanly separates the syntax of stock and flow diagrams from the semantics they can be assigned. We consider semantics in ordinary differential equations, although others are possible. As an example, we explain code in StockFlow that implements a simplified version of a COVID-19 model used in Canada.
翻译:存量-流量图广泛用于流行病学中建模人口动态。尽管已有工具可以构建这些图形并模拟其所描述的系统,但我们开发了一个名为StockFlow的新软件包(作为AlgebraicJulia生态系统的一部分),它利用范畴论的思想克服了现有软件的重要局限性。组合性由装饰cospan理论提供:存量-流量图可以通过直观的方式组合形成更大的图形,该方式由无向接线图操作体形式化。我们的方法还清晰地将存量-流量图的语法与可赋予的语义分离。我们考虑用常微分方程表示语义,尽管其他语义也是可能的。作为示例,我们解释了在加拿大的COVID-19简化版本模型中实现的StockFlow代码。