Population calculation using command and control in cycles¶
In this example, the calculation of population dynamics is realised on the basis of a non-linear, discrete model.
In the model, the population in a given year p(n) is proportional to the population of the previous year, p(n - 1), multiplied by the reproduction rate, p. However, resources are limited by L people, thus creating a negative impact on the population.
The figure below shows the model itself.

Next, let's connect the auxiliary function to start the model and declare initial states for it.
Out[0]:
run_model (generic function with 1 method)
Let's set the starting conditions as follows:
L = 1.0e6
p(0) = 1.0e5
r, we will change in the course of modelling:
- 1.5e-6 (the system converges)
- 2,2e-6 (2-cycle system)
- 2.5e-6 (4-cycle system)
- 2.56e-6 (8-cycle system)
Let's run the model in a cycle changing the value of r.
Building...
Progress 100%
Building...
Progress 100%
Building...
Progress 100%
Building...
Progress 100%
Let's display and compare the obtained results.
Conclusion¶
According to the results of the model, we see that the ideal population size is 1 million people, and with the coefficient 1.5e-6. In other cases, we observe population growth followed by population decline. In the case of scarcity of resources and the larger the coefficient r, the greater the diversity in population growth.
{"id": "fc13e0df-cc62-4ce4-a49c-dfe64d4e508a", "data": [{"showlegend": true, "mode": "lines", "xaxis": "x", "colorbar": {"title": {"text": ""}}, "name": "r = 1.5e-6", "zmin": null, "yaxis": "y", "legendgroup": "r = 1.5e-6", "zmax": null, "line": {"color": "rgba(0, 154, 250, 1.000)", "shape": "linear", "dash": "solid", "width": 1}, "y": [235000, 504662, 879629, 1038452, 978556, 1010032, 994833, 1002543, 998719, 1000638, 999680, 1000160, 999920, 1000040, 999980, 1000010, 999995, 1000002, 999999, 1000000, 1000000], "type": "scatter", "x": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21], "zaxis": null, "z": null, "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 21, "currentCount": 21}}}, {"showlegend": true, "mode": "lines", "xaxis": "x", "colorbar": {"title": {"text": ""}}, "name": "r = 2.2e-6", "zmin": null, "yaxis": "y", "legendgroup": "r = 2.2e-6", "zmax": null, "line": {"color": "rgba(227, 111, 71, 1.000)", "shape": "linear", "dash": "solid", "width": 1}, "y": [298000, 758231, 1161528, 748766, 1162620, 746676, 1162808, 746316, 1162839, 746257, 1162843, 746249, 1162844, 746247, 1162844, 746247, 1162844, 746247, 1162844, 746247, 1162844], "type": "scatter", "x": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21], "zaxis": null, "z": null, "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 21, "currentCount": 21}}}, {"showlegend": true, "mode": "lines", "xaxis": "x", "colorbar": {"title": {"text": ""}}, "name": "r = 2.5e-6", "zmin": null, "yaxis": "y", "legendgroup": "r = 2.5e-6", "zmax": null, "line": {"color": "rgba(62, 164, 78, 1.000)", "shape": "linear", "dash": "solid", "width": 1}, "y": [325000, 873438, 1149798, 719204, 1224078, 538356, 1159678, 696740, 1224973, 536008, 1157767, 701123, 1224997, 535945, 1157715, 701242, 1224996, 535948, 1157717, 701238, 1224996], "type": "scatter", "x": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21], "zaxis": null, "z": null, "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 21, "currentCount": 21}}}, {"showlegend": true, "mode": "lines", "xaxis": "x", "colorbar": {"title": {"text": ""}}, "name": "r = 2.56e-6", "zmin": null, "yaxis": "y", "legendgroup": "r = 2.56e-6", "zmax": null, "line": {"color": "rgba(195, 113, 210, 1.000)", "shape": "linear", "dash": "solid", "width": 1}, "y": [330400, 896764, 1133765, 745520, 1231203, 502479, 1142463, 725801, 1235277, 491258, 1131062, 751570, 1229554, 506996, 1146871, 715659, 1236596, 487607, 1127214, 760117, 1226905], "type": "scatter", "x": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21], "zaxis": null, "z": null, "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 21, "currentCount": 21}}}], "config": {"showlegend": true, "xaxis": {"showticklabels": true, "gridwidth": 0.5, "range": [0.3999999999999986, 21.6], "domain": [0.12508019830854475, 0.9934383202099737], "mirror": false, "tickangle": 0, "showline": true, "zeroline": false, "tickfont": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 11}, "zerolinecolor": "rgba(0, 0, 0, 1)", "anchor": "y", "visible": true, "ticks": "inside", "tickmode": "array", "linecolor": "rgba(0, 0, 0, 1)", "showgrid": true, "title": {"text": "", "font": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 15}}, "gridcolor": "rgba(0, 0, 0, 0.1)", "tickcolor": "rgb(0, 0, 0)", "type": "linear"}, "paper_bgcolor": "rgba(255, 255, 255, 1.000)", "annotations": [], "height": 400, "margin": {"l": 0, "b": 20, "r": 0, "t": 20}, "plot_bgcolor": "rgba(255, 255, 255, 1.000)", "yaxis": {"showticklabels": true, "gridwidth": 0.5, "range": [204952.12, 1266643.88], "domain": [0.03762029746281716, 0.9901574803149606], "mirror": false, "tickangle": 0, "showline": true, "zeroline": false, "tickfont": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 11}, "zerolinecolor": "rgba(0, 0, 0, 1)", "anchor": "x", "visible": true, "ticks": "inside", "tickmode": "array", "linecolor": "rgba(0, 0, 0, 1)", "showgrid": true, "title": {"text": "", "font": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 15}}, "gridcolor": "rgba(0, 0, 0, 0.1)", "tickcolor": "rgb(0, 0, 0)", "type": "linear"}, "legend": {"yanchor": "auto", "xanchor": "auto", "bordercolor": "rgba(0, 0, 0, 1)", "bgcolor": "rgba(255, 255, 255, 1.000)", "borderwidth": 1, "tracegroupgap": 0, "y": 1, "font": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 11}, "title": {"font": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 15}, "text": ""}, "traceorder": "normal", "x": 1}, "width": 319}}