[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-657258-105":59,"doc-detail-657258-en":130},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","compositional-modeling-with-stock-and-flow-diagrams-authoring-and-functorial-semantics-overview","Compositional Modeling with Stock and Flow Diagrams - Authoring and Functorial Semantics Overview","","Stock and flow diagrams are widely used in epidemiology to model population dynamics. While existing software can build such diagrams and simulate the represented systems, the StockFlow package improves on key limitations by introducing compositional modeling via decorated cospans and an operad-based wiring formalism. It separates diagram syntax from assigned meanings, focusing on differential-equation semantics. The paper demonstrates the approach with code implementing a simplified COVID-19 model used in Canada.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":40,"@type":76,"position":81},"https://docshare.wps.com/document/research-report/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/compositional-modeling-with-stock-and-flow-diagrams-authoring-and-functorial-semantics-overview/657258/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/compositional-modeling-with-stock-and-flow-diagrams-authoring-and-functorial-semantics-overview/657258.png","ImageObject",300,407,{"name":92,"@type":93},"lilac","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-10-30","2026-10-26",true,{"@type":102,"interactionType":103,"userInteractionCount":19},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What problem does the StockFlow package address in existing stock-and-flow modeling software?","Question",{"text":112,"@type":113},"The paper states that existing tools have notable limitations. StockFlow uses decorated cospans and wiring-diagram operads to support compositionality and to better organize the relationship between diagram syntax and semantics.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"What mathematical ideas enable composing stock and flow diagrams in StockFlow?",{"text":117,"@type":113},"Compositionality is provided by decorated cospans. Diagram composition is formalized using the operad of wiring diagrams, supporting intuitive construction of larger systems from parts.",{"name":119,"@type":110,"acceptedAnswer":120},"How are semantics for stock and flow diagrams handled in this work?",{"text":121,"@type":113},"The semantics are assigned in terms of ordinary differential equations, while noting that other semantics could be possible. The approach explicitly separates syntactic diagram structure from the semantic interpretation.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},657258,1793096731,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":39,"category_name":40,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":19,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":139,"language":140,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":67,"update_tm":144,"read_time":145},3985747861865,"https://ap-avatar.wpscdn.com/davatar_29158cc5080c5b710cf443261637dec0","Compositional Modeling with Stock and Flow Diagrams John Baez, Xiaoyan Li, Sophie Libkind, Nathaniel Osgood, and Evan Patterson  \nJuly 11, 2022  \nAbstract  \nStock 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 ofundirected 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.  \n1 Introduction  \nThe theoretical advantages of compositionality and functorial semantics are widely recognized among applied category theorists. Compositionality means, at the very least, that systems can be described one piece at a time, with a clear formalism for composing these pieces. This formalism can appear in various styles: composing morphisms in a category, tensoring objects in a monoidal category, composing operations in an operad, etc. Functorial semantics then means that the map from system descriptions (“syntax”) to their behavior (“semantics”) preserves all the relevant forms of composition.  \nWhile these principles are elegant, in many fields it is still a challenge to produce useful software that takes advantage of them and is embraced by the intended users. This is one of the main challenges of applied category theory. Here we focus on developing software suited to one particular field: epidemiological modeling. At present this software is additionally capable of modeling a wide class of systems studied in the System Dynamics modeling discipline [12, 29] .  \nThe AlgebraicJulia ecosystem of software implements compositionality and functorial semantics in a thorough-going way [1] . Decorated and structured cospans are broad mathematical frameworks for turning “closed” system descriptions into “open” ones that can be composed along their boundaries [10, 3 , 4] . One part of AlgebraicJulia, called Catlab [22], provides a generic interface for working with such cospans, among other categorical abstractions. With the help of Catlab, a tool called AlgebraicPetri was developed to work with one approach to epidemiological modeling based on Petri nets [18] . Here we explain a new tool, StockFlow, which handles a more flexible and more widely used formalism for epidemiological modeling: stock and flow diagrams.  \nIn Section 2 we review how stock and flow diagrams are used in epidemiological modeling, and discuss some shortcomings of existing software for working with these diagrams. In Section 3 we first use decorated cospans to formalize a simple class of open stock and flow diagrams and their differential equation semantics, and then sketch how to extend this class to the full-fledged diagrams actually used in our software. In Section 4 we describe the software package, StockFlow, that we have developed to work with stock-flow diagrams compositionally and implement a functorial semantics for them.1  \n1 The link to the StockFlow repository on GitHub is [https://github.com/AlgebraicJulia/StockFlow.jl](https://github.com/AlgebraicJulia/StockFlow.jl).  \nFigure 1: An example stock-flow diagram. This stock-flow diagram has three stocks labeled “Susceptible”, “Infective”, and “Recovered”; three flows labeled “Infection”,“Recovery”, and “Waning of Immunity”; many auxiliary variables including “Force of Infection” and “Total Population”; and links depicted by blue arrows.  \n2 Epidemiological model","cbCaioVNKgE6jE12","https://ap.wps.com/l/cbCaioVNKgE6jE12","pdf",2729761,17,"English","# Abstract\n# Introduction\n# Theoretical foundations of compositionality and functorial semantics\n## Epidemiological modeling context and motivation\n# Epidemiological modeling with stock and flow diagrams","[{\"question\":\"What problem does the StockFlow package address in existing stock-and-flow modeling software?\",\"answer\":\"The paper states that existing tools have notable limitations. StockFlow uses decorated cospans and wiring-diagram operads to support compositionality and to better organize the relationship between diagram syntax and semantics.\"},{\"question\":\"What mathematical ideas enable composing stock and flow diagrams in StockFlow?\",\"answer\":\"Compositionality is provided by decorated cospans. Diagram composition is formalized using the operad of wiring diagrams, supporting intuitive construction of larger systems from parts.\"},{\"question\":\"How are semantics for stock and flow diagrams handled in this work?\",\"answer\":\"The semantics are assigned in terms of ordinary differential equations, while noting that other semantics could be possible. The approach explicitly separates syntactic diagram structure from the semantic interpretation.\"}]","Compositional Modeling with Stock and Flow Diagrams - Authoring and Functorial Semantics Overview | PDF",1792976457,43]