StochSD | |
Developer: | Leif, Erik and Magnus Gustafsson |
Latest Release Version: | 2022.01.02 |
Programming Language: | JavaScript |
Operating System: | Windows, macOS, Linux |
Genre: | System Dynamics with stochastic extensions |
License: | GNU Affero General Public License |
StochSD[1] (Stochastic System Dynamics) is a free, open-source Continuous System Simulation (CSS) package intended for small and medium-sized models in education, self-studies and research.Technically, StochSD is based on the Insight Maker[2] engine with its DE-solver, function library, error checker, macro facility, etc., while the design, graphical user's interface, construction elements, result presentation, file handling, link checking, etc. are different. Also, tools for sensitivity analysis, and optimisation with or without constraints are included. In particular, StochSD includes features for stochastic modelling, post-analysis of multiple simulations, and presentation of the results in statistical form.
The design and development of StochSD were done during 2017–2022 with support from Uppsala University, Karolinska Institute, and the Swedish University of Agricultural Sciences.
StochSD was designed to fulfil the two purposes:
To support the use in education and self-studies, the StochSD package as well as course material to enable courses in classical CSS and Full Potential CSS modelling and simulation are provided at the StochSD website. This course material contains lectures, laboratory exercises, instructive models, and StochSD manuals, which mainly are based on material developed at Uppsala University and the Swedish University of Agricultural Sciences for courses in modelling and simulation.
StochSD is downloaded in many countries from all continents,[11] and can also be run directly in a web browser (of which there is no statistics). It is described, compared and discussed,[12] [13] [14] [15] [16] demonstrated in educational videos,[17] [18] [19] and also referred to in various languages.[20] [21] [22]
The Full Potential CSS concept is an extension of classical Continuous System Simulation, which provides the rules to make the results from macro-modelling consistent with those from micro-modelling.[6] [7] [8] [9]
Briefly, in addition to modelling and simulating continuous flows between stocks represented by ‘real numbers’, StochSD can also handle transitions of discrete entities by integer numbers. But in contrast to including individual entities into a CSS model, StochSD preserves the aggregated macro approach for discrete entities by transferring integer number of entities (e.g., arrivals, accidents, deaths) during a time-step.[6] However, such transitions may happen irregularly over time, so stochasticity often plays a crucial role in their modelling. Therefore, StochSD contains powerful random functions to model uncertainties of different kinds, as well as devices to collect statistics during a simulation and from multiple replications of the same stochastic model.[1] In StochSD the construction and simulation of e.g. queuing models[7] or combined discrete and continuous models[10] are done in a straightforward way (see example below).
The Full Potential concept also includes rules for how a stage has to be expanded into a structure of stocks and flows in order to reproduce a specific sojourn-time distribution, how attributes are to be handled, and where and how different types of uncertainty (structural, transition, initial value, parameter, and signal uncertainties) should be implemented.[9]
A continuous prey-predator model[23] [24] and a combined model with continuous prey (e.g. X= Grass) and discrete predators (e.g. Y = Sheep), as well as a replication of the combinedmodel are shown below.
Continuous model
\begin{array}{lll} X(t+DT)=X(t)+DT ⋅ (F1-F2-F3)&(CONTINUOUSGRASS)\\ F1=a ⋅ X&(Breeding)\\ F2=b ⋅ X ⋅ Y&(Preyedupon)\\ F3=c ⋅ X ⋅ X&(Internalcompetition)\\ Y(t+DT)=Y(t)+DT ⋅ (F4-F5)&(CONTINUOUSSHEEP)\\ F4=d ⋅ X ⋅ Y&(Births)\\ F5=e ⋅ Y&(Deaths)\\ \end{array}
Now assume that the births and deaths of the sheep are discrete random events with the expected rate d⋅X⋅Y and e⋅Y, respectively, then the number of events per time interval is Poisson distributed. The StochSD function PoFlow(expected_value) handles this by drawing a random number for each DT. The modifications to obtain a combined model are shown in red, below.
Combined discrete and continuous model
\begin{array}{lll} X(t+DT)=X(t)+DT ⋅ (F1-F2-F3)&(CONTINUOUSGRASS)\\ F1=a ⋅ X&(Breeding)\\ F2=b ⋅ X ⋅ Y&(Preyedupon)\\ F3=c ⋅ X ⋅ X&(Internalcompetition)\\ Y(t+DT)=Y(t)+DT ⋅ (F4-F5)&(DISCRETESHEEP)\\ F4=\color{red}PoFlow(\color{black}d ⋅ X ⋅ Y\color{red})\color{black}&(Discretebirths)\\ F5=\color{red}PoFlow(\color{black}e ⋅ Y\color{red})\color{black}&(Discretedeaths)\\ \end{array}
frame|left|The combined prey-predator model with continuous prey and discrete predators, and a replication of this model. (Note that the colouring of a primitive is preserved in the time plot.)
In the replication shown, the discrete predators became extinct at around 235 time units (e.g., months). The continuous prey then increases logistically to an equilibrium without further stochastic variations.
Comparing a continuous prey-predator model with the combined model reveals that the continuous model, starting at the equilibrium state (as in this example), will only produce two straight horizontal lines. Starting the continuous model outside the equilibrium state will make it approach the equilibrium for both species without lasting variations. Further, a phenomenon such as extinction cannot occur for a continuous model.
Creating the combined model, shown above, is straightforward. The traditional alternative of constructing a combined continuous and discrete model, with its mixture of disparate DES and CSS concepts, synchronisation of two different time-handling methods, and requiring a special combined simulation language is not an attractive option for a macro study.