Introduction to Dynamical Modeling

Veronika Zarnitsyna, Department of Microbiology and Immunology, Emory University School of Medicine, [email protected] June 14th, 2018

kBI

dI

rBI gB(1-B/B ) max Bacteria, B Immune Response, I “All models are wrong, but some are useful”.

George Box, 1978 Dynamical mechanistic models

• Dynamical: Tracking how things change in time • Mechanistic: Having equations or computer rules that explicitly describe how things happen

Within dynamical models, two broad classes are distinguished: • Deterministic: Assumption that the future is entirely predicted (determined) by the model • Stochastic: Assumption that random (stochastic) events affect the biological system, in which case a model can only predict the probability of various outcomes in the future Many types of Dynamical Models exist

Compartmental « Agent-based Discrete time « Continuous time Deterministic « Stochastic The models we’ll be Homogeneous « Spatial focusing on, formulated Memory-less « With memory as Ordinary Differential Equations Small « Big Data-free « With data

4 Modeling

The real world The conceptual world

Observations

Phenomena Model (analyses)

Predictions

Dym and Ivey 1980 5 Introduction to Dynamical models Veronika Zarnitsyna 6/14

Dynamical models are very common in biology as they provide insight into how various forces act to change a cell, an organism, a , or an assemblage of species. Within dynamical models, two broad classes are distinguished: deterministic and stochastic. “Deterministic” models are based on the assumption that the future is entirely predicted (determined) by the model. “Stochastic” models are based on the assumption that random (stochastic) events aect the biological system, in which case a model can only predict the probability of variousMalthusian outcomes in the growth future. We willmodel focus on (1798 deterministic) models. 1. Simple exponential(a simple growth exponential model growth model) Historically, the first attempts to describe the biological processes were the models. One of the famous model is Malthusian growth model (1798), sometimes called a simple model. This model is essentially exponentialdiscrete-time growth bacterial based on agrowth constant model rate. Let ‘B’ be, for example, the size of a population of bacteria that can change with time. If we assume that the rate of growth of the population is proportionalbirth to the sizedeath of the population, it will give rise to the following equation: B = B +(bB dB )· = B + gB · t+· t t ≠ t t t dB gB = gB dt Bacteria, B where g is the growth rate of theTotal number of population. The solution to this is time step bacteria at the gt next time step B(tterm )=describes how change B(0)e happens (the mechanisms) You canThomas Robert Malthus (1766 verify that this is-1834) the solution.Total number of bacteria right now We can plot the B(t) as a function of g. Before you look at the plots, think of what you might expect.

g=1 g=1 10000 g=0.3 g=0.3

g=0 1e+03 g=0 g=−1 g=−1 6000 1e+01 B(t) B(t) 01 − 1e 2000 03 0 − 1e 0 2 4 6 8 10 0 2 4 6 8 10

Time Time Notice:

1 Introduction to Dynamical models Veronika Zarnitsyna 6/14

Dynamical models are very common in biology as they provide insight into how various forces act to change a cell, an organism, a population, or an assemblage of species. Within dynamical models, two broad classes are distinguished: deterministic and stochastic. “Deterministic” models are based on the assumption that the future is entirely predicted (determined) by the model. “Stochastic” models are based on the assumption that random (stochastic) events aect the biological system, in which case a model can only predict the probability of various outcomes in the future. We will focus on deterministic models. 1. Simple exponential growth model Historically, the first attempts to describe the biological processes were the population dynamics models. One of the famous modelDiscrete is Malthusian- growthtime modelbacterial (1798), sometimes growth called model a simple exponential growth model. This model is essentially exponential growth based on a constant rate. Let ‘B’ be, for example, the size of a population of bacteria that can change with time. If we assume that the rate of growth of the population is proportionalbirth to the sizedeath of the population, it will give rise to the following equation: B = B +(bB dB )· = B + gB · t+· t t ≠ t t t dB = gB gB dt Bacteria, B where g is the growth rate of• theAssume population. b=12/hour, The solution d=2/hour, to this t=1 is hour. • B at start (t=0) B=( t100)=B(0)egt You can verify that this is the• What solution. do we get after 1,2,3,4,… hours? We can plot the population size B(t) as a function of g. Before you look at the plots, think of what you might expect.

g=1 g=1 10000 g=0.3 g=0.3

g=0 1e+03 g=0 g=−1 g=−1 6000 1e+01 B(t) B(t) 01 − 1e 2000 03 0 − 1e 0 2 4 6 8 10 0 2 4 6 8 10

Time Time Notice:

1 Introduction to Dynamical models IntroductionIntroduction to DynamicalIntroduction to Dynamical modelsVeronika to models Dynamical Zarnitsyna models Veronika Zarnitsyna IntroductionVeronika toVeronika Dynamical Zarnitsyna Zarnitsyna models6/14 6/14 6/14 6/14 DynamicalVeronika models Zarnitsyna are very common in biology as they provide insight into how various forces act to change a cell, an organism, a population, or an assemblage of species. Within dynamical models, two broad classes Dynamical models are6/14 very common in biology as they provide insight into how various forces act to change DynamicalDynamical models models are very are common very commonare in distinguished: biology in biology as they deterministic as provide they provide insight and insight stochastic. into how into various “Deterministic”how various forces forcesact models to act change to are change based on the assumption that the a cell, an organism, a population, or an assemblage of species. Within dynamical models, two broad classes a cell,a an cell, organism, an organism, a population, a population, or an assemblage or an assemblage of species. of species. Within Within dynamical dynamical models, models, two broad two broad classes classes arefuture distinguished: is entirely deterministic predicted (determined) and stochastic. by “Deterministic” the model. “Stochastic” models are models based on are the based assumption on the assumption that the are distinguished:are distinguished: deterministic deterministic and stochastic. and stochastic. “Deterministic” “Deterministic” models models are based are on based the on assumption the assumption that the that the Dynamical models are very commonfuturethat in is biology random entirely as (stochastic) predicted they provide (determined) events insight a intoect by the how the biological various model. forces “Stochastic” system, act in to which change models case are a based model on can the only assumption predict the futurefuture is entirely is entirely predicted predicted (determined) (determined) by the by model. the model. “Stochastic” “Stochastic” models models are based are based on the on assumption the assumption a cell, an organism, a population,that orprobability random an assemblage (stochastic) of various of species. outcomes events Within a inect the dynamical the future. biological We models, will system, focus two broad in on which deterministic classes case a model models. can only predict the that randomthat random (stochastic) (stochastic) events events aect a theect biological the biological system, system, in which in which case a case model a model can only can predict only predict the the are distinguished: deterministicprobability and stochastic. of various “Deterministic” outcomes models in the future. are based We on will the focus assumption on deterministic that the models. probabilityprobability of various of various outcomes outcomes in1. the Simple in future. the future. exponential We will We focus will growth on focus deterministic on model deterministic models. models. future is entirely predicted (determined) by the model. “Stochastic” models are based on the assumption 1. Simple exponential growth model 1.that Simple random1. Simple exponential (stochastic) exponential growth events growth aHistorically, modelect the model biological the first system, attempts in which to describe case a the model biological can only processes predict were the the population dynamics models. probability of various outcomesHistorically, inOne the future. of the the famous We first will attempts model focus is on Malthusian to deterministic describe growth the models. biological model (1798), processes sometimes were the called population a simple dynamics exponential models. growth Historically,Historically, the first the attempts first attempts to describe to describe the biological the biological processes processes were the were population the population dynamics dynamics models. models. Onemodel. of the This famous model model is essentially is Malthusian exponential growth model growth (1798), based sometimes on a constant called rate. a simple exponential growth One1. Simple ofOne the of famous exponential the famous model model is growth Malthusian is Malthusian model growth growth model model (1798), (1798), sometimes sometimes called called a simple a simple exponential exponential growth growth model. This model is essentially exponential growth based on a constant rate. model.model. This model This model is essentially is essentially exponentialLet ‘B’ exponential be, growth for example, growth based the basedon size a constant on of a a constant population rate. rate. of bacteria that can change with time. If we assume that the Historically, the first attempts to describe the biological processes were the population dynamics models. Letrate ‘B’ be, of growth for example, of the the population size of a is population proportional of bacteria to the size that of can the change population, with it time. will giveIf we rise assume to the that following the LetOne ‘B’ ofLet the be, ‘B’ forfamous be, example, for model example, the is size Malthusian the of size a population of growth a of bacteria of (1798), bacteria that sometimes can that change can called change with a time. simple with If time. exponential we assume If we assume that growth the that the rateequation: of growth of the population is proportional to the size of the population, it will give rise to the following ratemodel. ofrate growth This of model growth of the is of population essentially the population is exponential proportional is proportional growth to the based to size the of on size the a constant of population, the population, rate. it will it give will rise give to rise the to following the following equation:Ordinary DifferentialBt+ ·Equations= Bt +(bBt dB t(ODE))· = Bt + gBt· equation:equation: ≠ Let ‘B’ be, for example, the size of a population of bacteria that canBt+ change· = Bt with+(bB time.t dB If wet)· assume= Bt + thatgBt· the Bt+· =BtB+t·+(= bBBt t+(bBdBtt)· dB= Bt)t·+=gBBtt·+ gBt·Bt+·≠= Bt + gBt· rate of growth of the population is proportional to the≠ size of≠ the population, it will give rise to the following B = B + gB · B BB gBB · gB · t+B· t+· t Bt t equation: t+· = t+t·+= tt + t ≠ = gBt rewrite B ·B Bt+· = Bt +(bBt dBt)· = Bt + gBt· t+· t Bt+· B≠Bt+t· Bt ≠ = gBt ≠ =≠gBt = gBt · · · Bt+· = Bt + gBt· dB = gB Bt+· Bt dB dt dB≠ dB= gBt = gB where g is the growth· = gB rate= ofgB the population.t 0 Thedt solution to this is dt dt where g is the growth rate of the population. The solution to this is wherewhere g is the g isgrowth the growth rate of rate the of population. the population. ThedB solution The solution to this to is this is B(t)=B(0)egt = gB gt dt gt gt B(t)=B(0)e You can verifySolution:B(t that)=BB( thist(0))=e isB the(0)e solution. where g is the growth rate of the population. The solution to this is You can verify that this is the solution. You canYou verify can verify that this that is this the issolution. theWe solution. can plot the population size B(t) as a function of g. Before you look at the plots, think of what you gt Wemight can plot expect. theB( populationt)=B(0)e size B(t) as a function of g. Before you look at the plots, think of what you We canWe plot can the plot population the population size B size(t) asB( at) functionas a function of g. Before of g. Before you look you at look the at plots, the plots,think of think what of you what you might expect. Youmight canmight expect. verify expect. that this is the solution. We can plot the population size B(t) as a function of g. Before you look at the plots, think of what you might expect.

1 1 1 1

1 Introduction to Dynamical models IntroductionVeronika to Dynamical Zarnitsyna models Veronika Zarnitsyna 6/14 6/14 Dynamical models are very common in biology as they provide insight into how various forces act to change Dynamicala cell, an organism, models are a very population, common or in an biology assemblage as they of provide species. insight Within into dynamical how various models, forces two act broad to change classes aare cell, distinguished: an organism, deterministic a population, and or stochastic. an assemblage “Deterministic” of species. Within models dynamical are based on models, the assumption two broad that classes the arefuture distinguished: is entirely deterministic predicted (determined) and stochastic. by the “Deterministic” model. “Stochastic” models are models based are on based the assumption on the assumption that the futurethat random is entirely (stochastic) predicted events (determined) aect the by biological the model. system, “Stochastic” in which models case are a model based can on the only assumption predict the thatprobability random of (stochastic) various outcomes events in a theect future. the biological We will system, focus on in deterministic which case a models. model can only predict the probability1. Simple of exponential various outcomes growth in the model future. We will focus on deterministic models. 1.Historically, Simple exponential the first attempts growth to model describe the biological processes were the population dynamics models. Historically,One of the famous the first model attempts is Malthusian to describe growth the biological model (1798), processes sometimes were thecalled population a simple exponential dynamics models. growth Onemodel. of the This famous model model is essentially is Malthusian exponential growth growth model based (1798), on sometimes a constant called rate. a simple exponential growth model. This model is essentially exponential growth based on a constant rate. Let ‘B’ be, for example, the size of a population of bacteria that can change with time. If we assume that the Letrate ‘B’ of be, growth for example, of the population the size of is a proportional population of to bacteria the size that of the can population, change with it will time. give If we rise assume to the that following the rateequation: of growth of the population is proportional to the size of the population, it will give rise to the following equation: Bt+· = Bt +(bBt dBt)· = Bt + gBt· ≠ Bt+· = Bt +(bBt dBt)· = Bt + gBt· Bt+· =≠Bt + gBt· Malthusian growth model Bt+· = Bt + gBt· Bt+· Bt ≠ = gBt Bt+· · Bt g=1 g=1 gB 10000 ≠ = t g=0.3 g=0.3 · g=0 1e+03 g=0 dB g=−1 g=−1 = gB dBdt 6000

1e+01 = gB B(t) where g is the growthB(t) rate of the population. Thedt solution to this is 01

where g is the growth rate− of the population. The solution to this is 1e B t B egt

2000 ( )= (0) gt 03 B(t)=B(0)e 0 −

You can verify that this1e is the solution. 0 You2 can4 6 verify8 10 that this is0 the2 solution.4 6 8 10 We can plot the population size B(t) as a function of g. Before you look at the plots, think of what you Time Time Notice: Wemight can expect. plot the population size B(t) as a function of g. Before you look at the plots, think of what you

1. Populationsmight can change expect. over many orders of magnitude. It is useful to plot on a log scale. 2. The relationship between the growth rate g and the dynamics of : • g =0corresponds to a stable population

• g>0 generates an exponentially increasing population (proliferation) • g<0 generates an exponentially declining population (extinction)

2. Growth of human population Simple exponential growth model can describe the reproduction of bacteria, but in the case of sexual reproduction the underlying mechanism (and corresponding equation) is dierent. The sexual reproduction depends on the interaction of two sexes or genders. The reproduction will be proportional to the number of interactions between two sexes and, thus, the population growth will be proportional to the B to the power of two: dB = gB2 dt

The solution is: 1 B(t)= g(T t) 0 ≠ where 1 T = 0 gB(0)

Notice:

1. In the previous model the population increases to infinity as time goes to infinity. 2. In the current model, the rate is itself increasing with time, and the population size increases to infinity in finite time. The growth curve is displaying “superexponential” growth and has a vertical asymptote.

2

1 1 g=1 g=1 10000 g=0.3 g=0.3

g=0 1e+03 g=0 g=−1 g=−1 6000 1e+01 B(t) B(t) 01 − 1e 2000 03 0 − 1e 0 2 4 6 8 10 0 2 4 6 8 10

Time Time Notice:

1. Populations can change over many orders of magnitude. It is useful to plot populations on a log scale. 2. The relationship between the growth rate g and the dynamics of population growth: • g =0corresponds to a stable population

• g>0 generates an exponentially increasing population (proliferation) • g<0 generates an exponentially declining population (extinction)

54 ЛЕКЦИЯ 3 МОДЕЛИ РОСТА ПОПУЛЯЦИЙ 55 2. Growth of humanтем самооплодотворения population (микроорганизмы). Если же в основе дей — больше потенциальных изобретателей — ускорение тех- размножения лежит скрещивание, предполагающее встречи нологического роста — ускоренный рост несущей способности между особями разных полов одного и того же вида, то при- земли — еще более быстрый демографический рост — и так Simple exponentialрост будет growth тем выше model, чем больше canколичество describe встреч между the reproductionдалее (Коротаев of bacteria, и др., 2006). but in the case of sexual особями, а последнее пропорционально второй степени х. Та- Закономерности роста человеческой популяции подробно reproduction the underlyingким образом, для разнополой mechanism популяции в условиях (and неограни corresponding- equation)обсуждаются isв книгах di erent.«Общая теория The роста sexual человечества reproduction» ченных ресурсов можно записать С П Капицы и Биофизическая динамика продукцион . . [24] « - Капи&ца Сергей Петро dependsКурдю on&мов theСергей Пав interaction- of twodx sexes or genders. The reproductionных процессов will» Г. Ю be. Ризниченко proportional и А. Б. Рубина [29]. to the number- of 2 вич род лович (1928–2004) — = rx . Hyperbolic (3.6) growth of the ( . 1928) — российский советский российский матема- dt ученый и обществен interactionsтик, философ between, органи- two sexes and, thus, the population growth will be proportional to the B to the power- ный деятель Созда затор и популяризатор Решение этого уравнения . - тель и ведущий много науки. Автор теории - летних телевизионных of two: режимов с обостре- C 1 программ Очевидное нием. Один из основа- xt()= (3.7) 13 billions « - невероятное Разра телей синергетики как rT()− t dB ». - 0 2 ботал теорию глобаль области междисцип- - = gB ного роста человечест линарного знания. имеет вертикальную асимптоту то есть обращается в беско - , - ва как динамической

dt mln нечность в определенный момент времени t = T0. Такое пове- системы, в которой рост дение системы когда при приближении к определенному народонаселения мира , выражает суммарный моменту времени величина переменной начинает лавинооб- результат всей эконо- The solution is: мической, социальной разно нарастать, называется режимом с обострением [26]. Ко- и культурной деятель- нечно, такой рост в ограниченной среде не может соответст- 1 ности, составляющей историю человечества вовать реальности. С приближениемSolution: момента обостренияB(t)= . закон изменения численности с необходимостью меняется. g(T t) Хайнц фон Фёрстер 0 (von Foerster Heinz, ≠ 1911–2002) — австрий- population, Human ский и американский Рост человечества where физик, математик, один из основоположников 1 кибернетики. Первоот- Пример довольно длительного развития в соответствии крыватель закона ги T - с формулой (3.6) демонстрирует динамика общей численности0 = перболического роста gB народонаселения человечества (рис. 3.7). Впервые обратил внимание на этот (0) Земли. Малине&цкий Георгий факт фон Фёрстер [6, 7], который обработал с помощью мето- Геннадьевич (род. да наименьших квадратов данные о населении мира от Рождества Христова 1956) — российский Time, years ученый и обществен- и получил эмпирическую формулу гиперболической зависимости. С 60-х годов ный деятель Специа Notice: Рис Динамика численности человечества население мира . - ХХ века скорость роста человечества уменьшается — происходит так назы- . 3.7. : 1 — лист в области при- от г д н э до наших днейData fromмодель Birabenгиперболического, 1979 кладной математики ваемый глобальный демографический переход В древние времена возникнове 2000 . . . . ; 2 — , . - роста; 3 — область демографического перехода; 4 — предполагае- нелинейной динамики, математического мо- ния и первоначального роста человеческого вида гиперболический закон (3.7) мая стабилизация численности; 5 — древний мир; 6 — средние века; также не выполняется делирования истори- . 7 — новая история; 8 — новейшая история. N∞=12–13 млрд — пре- ческих и социальных 1. In theВ 1960 previous году в журнале modelScience Х. фон the Ферстер population опубликовал статью increases под назва- to infinityдел as роста time (Biraben, goes 1979, цит to. по Капица infinity., 1999). процессов. нием «Судный день. Пятница, 13 ноября 2026 года». Именно этот день, по его рас- 2. Inчетам theсоответствует currentмоменту model,обострения theдля кривой productivityчисленности народонасе rate is itself increasing with time, and the population size , « » - Модели с наименьшей критической численностью ления Земли (рис. 3.7). Качественно гиперболический рост численности населения increasesЗемли, наблюдавшийся to infinity вплоть до 1970- inх finite годов, можно time. объяснить The действием growth нели- curve is displaying “superexponential” growth and has a Уравнение (3.6) хорошо описывает тот факт, что при низких плотностях по- нейной положительной обратной связи, которая может быть схематически описана пуляций скорость размножения резко падает, так как вероятность встречи двух verticalследующим asymptote.образом технологический рост рост потолка несущей способности : — особей разных полов уменьшается при понижении плотности популяции пропор- земли (расширение экологической ниши) — демографический рост — больше лю-

2 and structure of semiconduc- in the "normal" semiconductors considered I have tried here to put the emphasis position here. on those basic properties that are com- tors on the one hand and parameters 11. P. Fielding, G. Fischer, E. Mooser, J. Phys. and that such as energy gap and charge-carrier Chem. Solids 8, 434 (1959). mon to all semiconductors 12. H. Winston, Phys. Rev. 94, 328 (1954). distinguish them from other solids. It mobility on the other. 13. S. Geller and J. H. Wernick, Acta Cryst. 12, is interesting as well as surprising to 46 (1959). 14. U. Winkler, Helv. Phys. Acta 28, 633 (1955). see how the many and various semi- References and Notes 15. P. Junod. E. Mooser, H. Schade, ibid. 29, conducting compounds are all governed 193 (1956). 1. A. H. Wilson, Proc. Roy. Soc. (London) 16. E. Mooser and W. B. Pearson, Phys. Rev. by the same simple chemical and struc- A133, 458 (1931). 101, 492 (1956). 2. , ibid. A134, 277 (1931). 893 tural rules. These rules present a chal- Z. 7a, 744 (1952). 17. , J. Chem. Phys. 26, (1957). 3. H. Welker, Naturforsch. G. F. U. Winkler, Helv. lenge to the theoretician, who has yet 4. The zinc blende structure can be considered 18. Busch, Hulliger, a superlattice of the diamond structure. Phys. Acta 27. 195 (1954). to interpret them in a rigorous way. 5. E. Mooser and W. B. Pearson, Progress in 19. J. Appel, Z. Naturforsch. 9a, 265 (1954). They present a challenge also to the Semiconductors, vol. 5 (Heywood, London, 20. E. Mooser and W. B. Pearson, J. Phys. Chem. in press). Solids 7, 65 (1958). experimentalist because they introduce 6. C. H. L. Goodman and R. W. Douglas, 21. G. Busch, E. Mooser, W. B. Pearson, Helv. Physica 20, 1107 (1954). Phys. Acta 29, 192 (1956). him to large families of new and un- 7. 0. G. Folberth and H. Pfister, Semiconduc- 22. E. Mooser and W. B. Pearson, Acta Cryst. explored semiconducting materials. And tors and Phosphors (Interscience, New York, 12, 1015 (1959). 1958), p. 474; I. G. Austin, C. H. L. Good- 23. F. Laves, Theory of Alloy Phases (American the challenge is all the greater since it man, A. E. S. Pengelly, J. Electrochem. Soc. Society for Metals, Cleveland, Ohio, 1956), is to be expected that, as our knowledge 103, 609 (1956); C. H. L. Goodman, Nature p. 124. 179, 828 (1957). 24. U. Dehlinger, Theoretische Metallkunde of semiconductors and their properties 8. E. Mooser and W. B. Pearson, J. Electronics (Springer, Berlin, 1955). increases, the chemical and structural 1, 629 (1956). 25. Since the principal quantum number of the 9. C. H. L. Goodman, J. Phys. Chem. Solids 6, valence shell of an atom coincides with the rules will be reflected in at present 305 (1958). number of the period in which the atom 10. While the mechanism of electronic conduction stands, one readily finds from Fig. 3 that, for largely unknown but much-sought-for in molecular compounds is not fully under- example, n = 4 for AlSb and n - 4.75 for relationships between the chemical com- stood at present, it certainly differs from that CuInTe-2.

rate of change of N, the number of elements in the population, is given by dN= N = ao N dt =YoN-Oo (1) where ao = yo - Oo may be called the Doomsday: productivity of the individual element. Friday, Depending upon whether ao : 0, inte- gration of Eq. 1 gives the well-known 13 November, A.D. 2026 exponential growth or decay of such a population with a time constant of l/ao. At this date human population will approach infinity In reality, alas, the situation is not if it grows as it has grown in the last two millenia. that simple, inasmuch as the two param- eters describing fertility and mortality may vary from element to element and, Heinz von Foerster, Patricia M. Mora, Lawrence W. Amiot moreover, fertility may have different values, depending on the age of a par- ticular element. To derive these distribution func- Among the many different aspects tion and has to be excluded from the tions from observations of the behavior which may be of interest in the study population count ("death"). of a population as a whole involves the of biological populations (1) is the one Under conditions which come close use of statistical machinery of consider- in which attempts are made to estimate to being paradise-that is, no environ- able sophistication (3, 4). the past and the future of such a popu- mental hazards, unlimited food supply, However, so long as the elements lation in terms of the number of its and no detrimental interaction be- live in our hypothetical paradise, it is elements, if the behavior of this popula- tween elements-the fate of a biologi- in principle possible, by straightforward tion is observable over a reasonable cal population as a whole is completely mathematical methods, to extract the period of time. determined at all times by reference to desired distribution functions, and the All such attempts make use of two the two fundamental properties of an fate of the population as a whole, with fundamental facts concerning an in- individual element: its fertility and its all its ups and downs, is again de- dividual element of a closed biological mortality. Assume, for simplicity, a fic- termined by properties exclusively at- population-namely, (i) that each ele- titious population in which all elements tributable to individual elements. If ment comes into existence by a sexual behave identically (equivivant popula- one foregoes the opportunity to de- or asexual process performed by an- tion, 2) displaying a fertility of /0 off- scribe the behavior of a population in other element of this population spring per element per unit time and all its temporal details and is satisfied ("birth"), and (ii) that after a finite having a mortality Oo = l/tm, derived The authors are members of the staff of the de- time each element will cease to be a from the life span for an individual ele- partment of electrical engineering, University of distinguishable member of this popula- ment of tm units of time. Clearly, the Illinois, Urbana. Heinz von Foerster (1911-2002) 4 NOVEMBER 1960 1291 A 1960 November issue of Science 3. Assumption of unconstrained growth. Of course, most populations are constrained by limitations on resources – even in the short run – and none is unconstrained forever.

3. Logistic growth model Logistic growth model Another classical example is the model of logistic growth. In 1838 the Belgian mathematician Verhulst introduced the logistic equation, which is aHow kind could of we generalization implement saturating of growth? the equation for exponential growth but with a maximum value for the population. The continuous time logistic growth model can be formulated as:

dB B = gB 1 dt ≠ B gB(1-B/Bmax) 3 max 4 Bacteria, B This is a non-linear first order dierential equation where Bmax is a . It is easiest to look at its behavior by using a computer to plot B(t) as a function of t for dierent growth rates g and initial conditions B(0). How can we compute B(t)? One way is to find the analytical solution, which is possible in this case.

B(0)B egt B(t)= max B B(0) + B(0)egt max ≠ However, in general, it is not possible to find the analytical solution of non-linear dierential equations, so we will briefly describe how we can do so using corresponding simulations. We will use a package ‘deSolve’ to find solutions. require(deSolve) # loading required package

## Loading required package: deSolve

## Warning: package deSolve was built under R version 3.3.2 logistic.model <- function(t, y, parms) { with(as.list(c(y,parms)),{ dB = g*B*(1-B/Bmax) dy=c(dB) return(list(dy)) }) }

# Model parameters parameters=list(g=2,Bmax=10^5,tmax=10) # time in days

# Initial conditions Bini=c(B=1)

# Run simulation time.points = seq(0, parameters$tmax, parameters$tmax/100) # timepoints for output Bsolution=ode(y=Bini, time=time.points, logistic.model, parms=parameters)

# plot timecourse of infection # 1st plot with number on y axis plot(Bsolution[,1],Bsolution[,2], ylim=c(0,2*10^5), log="", type="l", xlab="Time (days)",

3 ylab="B", col="red", lwd=2) # change initial3. conditionsAssumption of unconstrained growth. Of course, most populations are constrained by limitations on Bini=c(B=1000) Bsolution=ode(y=Bini, time=time.points, logistic.model, parms=parameters) lines(Bsolution[,resources1],Bsolution[,2], –col= even"red",lty= in2,lwd= the2) short run – and none is unconstrained forever. # change initial conditions Bini=c(B=7*10^4) Bsolution=ode(y=Bini, time=time.points, logistic.model, parms=parameters) lines(Bsolution[,1],Bsolution[,2], col="red",lty=3,lwd=2) Introduction# change3. initial Logistic conditions to Dynamical growth model models Bini=c(B=2*10^5) Bsolution=ode(y=VeronikaBini, time= Zarnitsynatime.points, logistic.model, parms=parameters) lines(Bsolution[,1],Bsolution[,2], col="red",lty=4,lwd=2) Another classical6/14 example is the model of logistic growth. In 1838 the Belgian mathematician Verhulst ablineintroduced(h=parameters$Bmax, col= the"black"Logistic logistic, untf=TRUE, equation,lty=2 ,growthlwd=2) which model is a kind of generalization of the equation for exponential growth but abline(h=parameters$Bmax/2, col="black", untf=TRUE, lty=2, lwd=1) Dynamical models are verylegend common("topright" in biology, c("B(t=0)=1" as they provide, "B(t=0)=10^2" insight, into"B(t=0)=10^4" how various, "B(t=0)=2*10^5" forces act to change), lty=c(1,2,3,4), col="red") a cell, an organism, a population,with or an assemblage a maximum of species. Within value dynamical for models, the population.two broad classes The continuous time logistic growth model can be formulated as: are distinguished: deterministic and stochastic. “Deterministic” models are based on the assumption that the B(t=0)=1 future is entirely predicted (determined) by the model. “Stochastic” models are based on the assumption B(t=0)=10^2 that random (stochastic) events aect the biological system, in which case a model can only predict the B(t=0)=10^4 probability of various outcomes in the future. We will focus on deterministic models. dB B B(t=0)=2*10^5 = gB 1 1. Simple exponential growth150000 model dt ≠ Bmax B 3 4 Historically, the first attemptsB max to describe the biological processes were the population dynamics models. One of the famous model is Malthusian growth model (1798), sometimes called a simple exponential growth model. This model is essentiallyThis exponential is growth a non-linear based on a constant first rate. order dierentialg=2 equation where Bmax is a carrying capacity. Bmax/2 Let ‘B’ be, for example, the size of a population of bacteria that can change with time. If we assume that the B =105 50000 max rate of growth of the population is proportional to the size of the population, it will give rise to the following equation: It is easiest to look at its behavior by using a computer to plot B(t) as a function of t for dierent growth

0 B = B +(bB dB )· = B + gB · ratest+· gt andt ≠ initialt t conditionst B(0). How can we compute B(t)? One way is to find the analytical solution, 0 Bt+· =2 Bt + gBt· 4 6 8 10 which isB possibleB in this case. t+· ≠ t = gB · t Time (days)

1 Bmax B(0) B t Notice: the logistic growthln equation( has≠ an important) feature. If initial value of population ( = 0) is small, gt the size of population Bg will increase.B(0) If initial value of B(t = 0) is large, the size of population B will B(0)Bmaxe approach to the limit Bmax. B(t)= We can rescale B as a fractiondB of the carrying capacity Bmax to get gt = gB Bmax B(0) + B(0)e dB dt = gB(1 B) ≠ where g is the growth rate of the population. The solution to thisdt is ≠ require(deSolve) # loading required package However,B(t)= inB general,(0)egt it is not possible to find the analytical solution of non-linear dierential equations, so we logistic.model2 <- function(t, y, parms) { You can verify that this iswith the( solution.willas.list( brieflyc(y,parms)),{ describe how we can do so using corresponding simulations. dB = g*B*(1-B) We can plot the populationdy= sizec(dB)B(t) as a function of g. Before you look at the plots, think of what you might expect. We will use a package ‘deSolve’ to find solutions. 4 require(deSolve) # loading required package

## Loading required package: deSolve

## Warning: package deSolve was built under R version 3.3.2

logistic.model1 <- function(t, y, parms) { with(as.list(c(y,parms)),{ dB = g*B*(1-B/Bmax) dy=c(dB) return(list(dy)) }) }

# Model parameters parameters=list(g=2,Bmax=10^5,tmax=10) # time in days

# Initial conditions Bini=c(B=1)

# Run simulation time.points = seq(0, parameters$tmax, parameters$tmax/100) # timepoints for output Bsolution=ode(y=Bini, time=time.points, logistic.model, parms=parameters)

# plot timecourse of infection # 1st plot with number on y axis plot(Bsolution[,1],Bsolution[,2], ylim=c(0,2*10^5), log="", type="l", xlab="Time (days)",

3 # Plot with number on y axis plot(Bsolution[,1],Bsolution[,2], ylim=c(0.0,max(Bsolution[,2],Bsolution[,3])), log="", col="green", lwd=2, type="l", xlab="time (years)", ylab="number", main="predator-prey model") lines(Bsolution[,1],Bsolution[,3], col="red", lwd=2) # Plot with number on y axis legend("topright", legend=c("Prey", "Predator"), lty=1, lwd=2, col=c("green", "red")) plot(Bsolution[,1],Bsolution[,2], ylim=c(0.0,max(Bsolution[,2],Bsolution[,3])), log="", col="green", lwd=2, type="l", xlab="time (years)", ylab="number", main="predator-prey model") plot(Bsolution[,2],Bsolution[,3], type="b", xlab="Prey", ylab="Predator") lines(Bsolution[,1],Bsolution[,3], col="red", lwd=2) legend("topright", legend=c("Prey", "Predator"), lty=1, lwd=2, col=c("green", "red")) predator−prey model plot(Bsolution[,2],Bsolution[,3], type="b", xlab="Prey", ylab="Predator") predator−prey model Prey 10 25 Predator 8

Prey 20 10 25 Predator 6 15 8 20 number Predator 4 10 6 15 2 5 number Predator 4 10 0 0 2 5 0 10 20 30 40 50 0 5 10 15 20 25 0 0 time (years) Prey 0 10 20 30 40 50 0 5 10 15 20 25 Equations for the presentation slides 3. Assumption of unconstrained growth. Of course, most populations are constrained by limitations on time (years) PreyB = B +(bB dB )· = B + gB · resources – even in the short run – and none is unconstrained forever.t+· t t ≠ t t t

Equations for the presentation slides Bt+· = Bt + gBt· 3. Logistic growth model Bt+· Bt Bt+· = Bt +(bBt dBt)· = Bt + gBt· ≠ = gB Another classical example is the model≠ of logistic growth. In 1838 the Belgian mathematician· t Verhulst introduced the logistic equation, which is a kind of generalizationLogistic ofgrowth the equation model for exponential growth but Bt+· = Bt + gBt· 1 B B(0) with a maximum value for the population. The continuous time logistic growth modelln( max can≠ be formulated) as: B B g B(0) t+· ≠ t = gB · t dB B dB 2 = gB 1 = gB ”B 1 Bmax dtB(0) ≠ B rewrite dt ≠ ln( ≠ ) 3 max 4 g B(0) # install.packages(devtools) This is a non-linear first order didBerential equation where Bmax is a carrying capacity. #= library(gB ”Bis2 adevtools coefficient for) intraspecific It is easiest to look at its behaviordt # by install_github( using≠ a computerahgroup/DSAIRM to plot B(t) as a) function of t for dierent growth rates g and initial conditions B(0)#. How library( can weDSAIRM compute) B(t)? One way is to find the analytical solution, # install.packages(devtools) Members of the same species compete for limited essential resources, which is possible in this case. # dsairmmenu()for example, for food, space, mates or any other which is # library(devtools) required for survival or reproduction. # install_github(ahgroup/DSAIRM) B(0)B egt # library(DSAIRM) B(t)= max B B(0) + B(0)egt # dsairmmenu() max ≠ However, in general, it is not possible to find the analytical solution of non-linear dierential equations, so we will briefly describe how we can do so using corresponding simulations. 8 We will use a package ‘deSolve’ to find solutions. require(deSolve) # loading required8 package

## Loading required package: deSolve

## Warning: package deSolve was built under R version 3.3.2 logistic.model <- function(t, y, parms) { with(as.list(c(y,parms)),{ dB = g*B*(1-B/Bmax) dy=c(dB) return(list(dy)) }) }

# Model parameters parameters=list(g=2,Bmax=10^5,tmax=10) # time in days

# Initial conditions Bini=c(B=1)

# Run simulation time.points = seq(0, parameters$tmax, parameters$tmax/100) # timepoints for output Bsolution=ode(y=Bini, time=time.points, logistic.model, parms=parameters)

# plot timecourse of infection # 1st plot with number on y axis plot(Bsolution[,1],Bsolution[,2], ylim=c(0,2*10^5), log="", type="l", xlab="Time (days)",

3 # change initial conditions Bini=c(B=0.1) Bsolution=ode(y=Bini, time=time.points, logistic.model2, parms=parameters) lines(Bsolution[,1],Bsolution[,2], col="red",lty=2,lwd=2) # change initial conditions Bini=c(B=0.5) Bsolution=ode(y=Bini, time=time.points, logistic.model2, parms=parameters) lines(Bsolution[,1],Bsolution[,2], col="red",lty=3,lwd=2) # change initial conditions Bini=c(B=2) Bsolution=ode(y=Bini, time=time.points, logistic.model2, parms=parameters) lines(Bsolution[,1],Bsolution[,2], col="red",lty=4,lwd=2) legend("topright", c("B(t=0)=0.001", "B(t=0)=0.1", "B(t=0)=0.5", "B(t=0)=2"), lty=c(1,2,3,4), col="red")

2.0 B(t=0)=0.001 B(t=0)=0.1 B(t=0)=0.5

1.5 B(t=0)=2 B 1.0 0.5 0.0

# change initial0 conditions 2 4 6 8 10 Bini=c(B=0.1) Bsolution=ode(y=Bini, time=time.points, logistic.model2, parms=parameters) lines(Bsolution[,1],Bsolution[,2], col="red",lty=2,lwd=2) # change initial conditions Time (days) Bini=c(B=0.5) Bsolution=ode(y=Bini, time=time.points, logistic.model2, parms=parameters) Notice: thelines logistic(Bsolution[, growth1],Bsolution[, equation2], col= has"red" an,lty= important3,lwd=2) feature. If initial value of population B(t = 0) is small, the size# changeof population initial conditionsB will increase. If initial value of B(t = 0) is large, the size of population B will Bini=c(B=2) approachBsolution= to theode limit(y=Bini,Bmaxtime=.time.points, logistic.model2, parms=parameters) lines(Bsolution[,1],Bsolution[,2], col="red",lty=4,lwd=2) 4. Lotka–Volterralegend("topright", c equations,("B(t=0)=0.001", "B(t=0)=0.1" also known, "B(t=0)=0.5" as the, "B(t=0)=2" predator–prey), lty=c(1,2,3,4 model), col="red")

Let us consider2.0 a simple predator-prey model with B nowB(t=0)=0.001 being the prey and I being the predator. B(t=0)=0.1 From Biology to Model. B(t=0)=0.5

1.5 B(t=0)=2 1. Prey grows exponentially in the absence of the predator B 2. Predator1.0 finds and eats prey (law of mass action) Lotka3. The–Volterra rate of increaseequations in the predator (predator population–prey depends model) on how many prey are consumed.

4. Predators0.5 have a fixed death rate

0.0 dB prey = gB kBI 0 2 4 6 dt 8 ≠ 10 Time (days) dI predator = rBI dI Notice: the logistic growth equation has an important feature. If initial valuedt of population B(≠t = 0) is small, the size of population B will increase. If initial value of B(t = 0) is large, the size of population B will approach to the limit Bmax. 4. Lotka–Volterra equations, also known as the predator–prey model5 Let us consider a simple predator-prey model with B now being the prey and I being the predator. Alfred James LotkaFrom(1880 Biology–1949) to Model.Vito Volterra (1860 –1940)

1. Prey grows exponentially in the absence of the predator 2. Predator finds and eats prey (law of mass action) 3. The rate of increase in the predator population depends on how many prey are consumed. 4. Predators have a fixed death rate

dB prey = gB kBI dt ≠ dI predator = rBI d I dt ≠ I

5 # change initial conditions Bini=c(B=0.1) Bsolution=ode(y=Bini, time=time.points, logistic.model2, parms=parameters) lines(Bsolution[,1],Bsolution[,2], col="red",lty=2,lwd=2) # change initial conditions Bini=c(B=0.5) Bsolution=ode(y=Bini, time=time.points, logistic.model2, parms=parameters) lines(Bsolution[,1],Bsolution[,2], col="red",lty=3,lwd=2) # change initial conditions Bini=c(B=2) Bsolution=ode(y=Bini, time=time.points, logistic.model2, parms=parameters) lines(Bsolution[,1],Bsolution[,2], col="red",lty=4,lwd=2) legend("topright", c("B(t=0)=0.001", "B(t=0)=0.1", "B(t=0)=0.5", "B(t=0)=2"), lty=c(1,2,3,4), col="red")

2.0 B(t=0)=0.001 B(t=0)=0.1 B(t=0)=0.5

1.5 B(t=0)=2 B 1.0 0.5 0.0

0 2 4 6 8 10

Time (days)

Notice: the logistic growth equation has an important feature. If initial value of population B(t = 0) is small, the size of population B will increase. If initial value of B(t = 0) is large, the size of population B will approach to the limit Bmax. 4. Lotka–Volterra equations, also known as the predator–prey model Let us consider a simple predator-prey model with B now being the prey and I being the predator. From Biology to Model.

1. Prey grows exponentially in the absence of the predator 2. Predator finds and eats prey (law of mass action) 3. The rate of increase in the predator population depends on how many prey are consumed. 4. Predators have a fixed death rate Lotka–Volterra equations (predator–prey model) dB prey = gB kBI dt ≠ dI predator = rBI dI dt ≠ Parameter Description Units g Represent the reproduction rate of the prey. The greater g is, the more rapidly the prey 5 1/time reproduces. k Represents the death rate of the prey due to the presence of the predator. The greater k is, 1/time the greater the death of the prey is due to and the more effective the predator is killing the prey. r Represents the reproduction rate of the predator. The greater r is, the more rapidly the 1/time predator reproduces and the more effectively the prey is able to nourish the predator. d Represents the death rate of the predator. 1/time # change initial conditions Bini=c(B=0.1) Bsolution=ode(y=Bini, time=time.points, logistic.model2, parms=parameters) lines(Bsolution[,1],Bsolution[,2], col="red",lty=2,lwd=2) # change initial conditions Bini=c(B=0.5) Bsolution=ode(y=Bini, time=time.points, logistic.model2, parms=parameters) lines(Bsolution[,1],Bsolution[,2], col="red",lty=3,lwd=2) # change initial conditions Bini=c(B=2) Bsolution=ode(y=Bini, time=time.points, logistic.model2, parms=parameters) lines(Bsolution[,1],Bsolution[,2], col="red",lty=4,lwd=2) legend("topright", c("B(t=0)=0.001", "B(t=0)=0.1", "B(t=0)=0.5", "B(t=0)=2"), lty=c(1,2,3,4), col="red")

2.0 B(t=0)=0.001 B(t=0)=0.1 B(t=0)=0.5

1.5 B(t=0)=2 B 1.0 0.5 0.0

0 2 4 6 8 10

Time (days)

Notice: the logistic growth equation has an important feature. If initial value of population B(t = 0) is small, the size of population B will increase. If initial value of B(t = 0) is large, the size of population B will approach to the limit Bmax. 4. Lotka–Volterra equations, also known as the predator–prey model Let us consider a simple predator-prey model with B now being the prey and I being the predator. From Biology to Model.

1. Prey grows exponentially in the absence of the predator 2. Predator finds and eats prey (law of mass action) 3. The rate of increase in the predator population depends on how many prey are consumed. 4. Predators have a fixed death rateLotka–Volterra equations (predator–prey model) predator−prey model

dB Prey 25 prey = gB kBI 50 Predator

dt ≠ 20

Steady states 40 dI

predator = rBI dI 15 We can look for steady states of the model by setting dB/dtdt and≠ dI/dt to zero.30 There are two steady states. number Predator

One has no predator or prey (B=I=0) and in the other the numbers or densities of predator and prey are:10 20 Steady state:5 5 d g 10 Bú = Iú = 0 r k 0 0 10 20 30 40 50 0 10 20 30 40 50 Lets do a thought experiment using the equations of predator–prey model. Consider the use of a pesticide to control an agricultural pest B which has a natural predator I. time (years) Prey What is the eect of changing the initial conditions? What will be the eect of introducing a carrying capacity to prey? How will it change the steady states? What is the effect of changing initial conditions? 1. Prey = pest, Predator = natural predator of pest require(deSolve) # the equations for the predator-prey model area here pp.model2 <- function(t, y, parms) { 2. Eect of pesticide on parameters? with(as.list(c(y,parms)), # allows you to refer to parameters and state variables by name { dB = g*B*(1-B/Bmax) - k*B*I # prey • decrease the growth rate of the prey g dI = r*B*I - d*I # predators • increase the death rate of predator dI dy=c(dB, dI) return(list(dy)) }) } Consider a reduction in g and an increase in d by a factor f>1.ThenewequilibriumdensityB will be f I #model parameters ú times as high as the one prior to use of the pesticide and the density ofparameters= its naturallist(g=2 predator,k=0.5,r=0.5/3, ad=0.6 factor, Bmax=40f) lower. # initial conditions init.cond=c(B=.1,I=.1) require(deSolve) #Time points to run the simulation tmax=50 # the equations for the predator-prey model area here npoints=1000 time.points = seq(0, tmax, tmax/npoints) # timepoints for output pp.model <- function(t, y, parms) { with(as.list(c(y,parms)), # allows you to refer to parametersBsolution=ode and(y=init.cond, statetime= variablestime.points, pp.model2, by nameparms=parameters) { par(mfcol=c(1,2)) dB = g*B - k*B*I # prey 7 dI = r*B*I - d*I # predators dy=c(dB, dI) return(list(dy)) }) }

#model parameters parameters=list(g=2,k=0.5,r=0.5/3,d=0.6)

# initial conditions init.cond=c(B=.1,I=.1) #Time points to run the simulation tmax=50 npoints=1000 time.points = seq(0, tmax, tmax/npoints) # timepoints for output

Bsolution=ode(y=init.cond, time=time.points, pp.model, parms=parameters) par(mfcol=c(1,2)) # Plot with number on y axis plot(Bsolution[,1],Bsolution[,2], ylim=c(0.0,max(Bsolution[,2],Bsolution[,3])), log="", col="green", lwd=2, type="l", xlab="time (years)", ylab="number", main="predator-prey model") lines(Bsolution[,1],Bsolution[,3], col="red", lwd=2) legend("topright", legend=c("Prey", "Predator"), lty=1, lwd=2, col=c("green", "red")) plot(Bsolution[,2],Bsolution[,3], type="b", xlab="Prey", ylab="Predator")

6 predator−prey model predatorpredator−−preyprey model model

Prey 25 25 PreyPrey 25 50 Predator 50 50 PredatorPredator 20 20 20 40 40 40 15 15 15 30 30 30 number Predator 10 number number Predator Predator 20 10 10 20 20 5 10 5 5 10 10

time.points = seq(0, tmax, tmax/npoints) # timepoints for output 0 0 Bsolution=ode(y=init.cond, time=time.points, pp.model2, parms=parameters) 0 0 0 0

par(mfcol=c(1,2)) # Plot with number on y axis 0 10 20 30 40 50 0 10 plot20(Bsolution[,301],Bsolution[,40 250], ylim=c(0.0,max(Bsolution[,2],Bsolution[,3])), log="", col="green", lwd=2, type="l", xlab="time (years)", 00 1010 2020 3030 4040 5050 00 1010 2020 3030ylab=40"number"40 ,50main=50"predator-prey model modified") lines(Bsolution[,1],Bsolution[,3], col="red", lwd=2) legend("topright", legend=c("Prey", "Predator"), lty=1, lwd=2, col=c("green", "red")) time (years) Prey timetime (years) (years) Addition of carryingPreyPreyplot(Bsolution[, capacity2],Bsolution[,3], type= to"b", xlab= the"Prey", ylab=prey"Predator" ) What is the eect of changing the initial conditions? predator−prey model modified WhatWhat is is the the e eectect of of changing changing the the initial initial conditions? conditions? Prey

What will be the eect of introducing a carrying capacity to prey? How will it change the steady states? 10 WhatWhat will will be be the the e eectect of of introducing introducing a a carrying carrying capacity capacity to to prey? prey? How How will will it it change change25 the the steady steady states? states?Predator 8 dB B 20 preydBdB = gBB(1B ) kBI 6 preyprey ==gBgBdt(1(1 ≠) )BmaxkBIkBI≠ 15 dtdt ≠≠BBmaxmax ≠≠ number Predator 4

dI 10 predatordIdI = rBI dI rBIrBIdt dIdI ≠

predatorpredator == 2 dtdt ≠≠ 5 require(deSolve) 0 0 requirerequire#(deSolve) the(deSolve) equations for the predator-prey model area here 0 10 20 30 40 50 0 5 10 15 20 25 ## the the equationspp.model2 equations for<- forfunction(t, the the predator-prey predator-prey y, parms) model model { area area here here pp.model2pp.model2with <- <-(function(t,as.listfunction(t,(c(y,parms)), y, y, parms) parms) {# { allows you to refer to parameters and statetime (years) variables by name Prey withwith(as.list(as.list(c((y,parms)),c(y,parms)), ## allows allows you you to to refer refer to to parameters parameters and andLets state do state a thought variables experiment variables using the equations by by name of name predator–prey model. Consider the use of a pesticide to { control an agricultural pest B which has a natural predator I. {{ dB = g*B*(1-B/Bmax) - k*B*I # prey 1. Prey = pest, Predator = natural predator of pest dBdB = =g*B*(dIg*B*( =1-B/Bmax)r*B*I1-B/Bmax) - d*I - -k*B*Ik*B*I# predators## prey prey dIdI = =r*B*Ir*B*I - -d*Id*I ## predators predators 2. Eect of pesticide on parameters? • decrease the growth rate of the prey g dy=c(dB, dI) • increase the death rate of predator d dy=dy=c(dB,c(dB, dI) dI) Consider a reduction in g and an increase in d by a factor f>1.ThenewequilibriumdensityB will be f return(list(dy)) ú times as high as the one prior to use of the pesticide and the density of its natural predator a factor f lower. returnreturn})(list(list(dy))(dy)) })}) Equations for the presentation slides } Bt+· = Bt +(bBt dBt)· = Bt + gBt· }} ≠ #model parameters 8 #model#modelparameters= parameters parameterslist(g=2,k=0.5,r=0.5/3,d=0.6, Bmax=40) parameters=parameters=listlist(g=(g=2,2k=,k=0.50.5,r=,r=0.50.5/3/,3d=,d=0.60.6,,Bmax=Bmax=4040)) # initial conditions ## initial initialinit.cond= conditions conditionsc(B=.1,I=.1) init.cond=init.cond=#Timec(cB= points(B=.1.,1I=,I=. to1.)1 run) the simulation #Time#Time pointstmax= points50 to to run run the the simulation simulation tmax=tmax=50npoints=50 1000 npoints=npoints=10001000

7 77 predator−prey model predator−prey model

Prey 25 25 50 Prey Predator 50 Predator 20 20 40 40 15 30 15 30 number Predator 10 number 20 Predator 10 20 5 10 5 10 0 0 0 0 0 10 20 30 40 50 0 10 20 30 40 50 0 10 20 30 40 50 0 10 20 30 40 50 time (years) Prey time (years) Prey What is the eect of changing the initial conditions? What is the eect of changing the initial conditions?Thought experiment What will be the eect of introducing a carrying capacity to prey? How will it change the steady states? What will be the eect of introducing a carrying capacity to prey? How will it change the steady states? dB B Pest preydB = gBB(1 ) kBI prey = gBdt(1 ≠) BkBImax ≠ dt ≠ BmaxdI ≠ predatordI = rBI dI Predatorpredator of pest = rBIdt dI ≠ dt ≠ require(deSolve) require#(deSolve) the equations for the predator-prey model area here # the equationspp.model2What for <- function(t, the will predator-preybe the effect y, parms) of modelpesticide { area on hereparameters? pp.model2with <- (function(t,as.list(c(y,parms)), y, parms) {# allows you to refer to parameters and state variables by name with(as.list{(c•(y,parms)),decrease the# growth allows rate you of to the refer prey g to parameters and state variables by name { dB• increase = g*B*( 1the-B/Bmax) death rate - k*B*I of predator# prey d dB = g*B*(dI =1-B/Bmax)r*B*I - d*I - k*B*I# predators# prey dI = r*B*I - d*I # predators Consider a reduction in g and an increase in d by a factor f>1 and run the simulations dy=c(dB, dI) dy=c(dB,return dI) (list(dy)) return})(list(dy)) }}) } #model parameters #modelparameters= parameters list(g=2,k=0.5,r=0.5/3,d=0.6, Bmax=40) parameters=list(g=2,k=0.5,r=0.5/3,d=0.6, Bmax=40) # initial conditions # initialinit.cond= conditionsc(B=.1,I=.1) init.cond=#Timec(B= points.1,I=. to1) run the simulation #Time pointstmax=50 to run the simulation tmax=50npoints=1000 npoints=1000

7 7 predator−prey model

Prey 25

50 Predator 20 40 15 30 number Predator 10 20 5 10 0 3. Assumption of unconstrained growth. Of course,0 most populations are constrained by limitations on resources – even in the short run – and none is unconstrained forever. 0 10 20 30 40 50 0 10 20 30 40 50 3. Logistic growth model Another classicaltime example(years) is the model of logisticAddition growth. immune In 1838Prey response the Belgian mathematician to Verhulst introduced the logistic equation, which is a kind of generalization of the equation for exponential growth but What is the eect of changing the initial conditions? with a maximum value for the population. The continuousbacteria time growth logistic growth model model can be formulated as: What will be the eect of introducing a carrying capacity to prey? How will it change the steady states? dB B bacteriadB = gBB 1 prey = gB(1dt ) ≠kBIBmax dt ≠ Bmax3 ≠ 4 This is a non-linear first order dierentialdI equation where B is a carrying capacity. predatorimmune = rBI dI max response dt ≠ It is easiest to look at its behavior by using a computer to plot B(t) as a function of t for dierent growth requirerates(deSolve)g and initial conditions B(0). How can we compute B(t)? One way is to find the analytical solution, # the equationswhich is possible for the in predator-prey this case. model area here pp.model2 <- function(t, y, parms) { What is missing? with(as.list(c(y,parms)), # allows you to refer to parameters and state variables by name B(0)B egt { B(t)= max B B(0) + B(0)egt dB = g*B*(1-B/Bmax) - k*B*I # prey max ≠ dI = r*B*I - d*I # predators However, in general, it is not possible to find the analytical solution of non-linear dierential equations, so we willdy= brieflyc(dB, describe dI) how we can do so using corresponding simulations. Wereturn will use(list a package(dy)) ‘deSolve’ to find solutions. }) } require(deSolve) # loading required package #model parameters parameters=## Loadinglist(g=2 required,k=0.5,r=0.5 package:/3,d=0.6 deSolve, Bmax=40)

# initial conditions init.cond=##c Warning:(B=.1,I=. package1) deSolve was built under R version 3.3.2 #Time points to run the simulation tmax=50logistic.model <- function(t, y, parms) { npoints=1000with(as.list(c(y,parms)),{ dB = g*B*(1-B/Bmax) dy=c(dB) return(list(dy)) 7 }) }

# Model parameters parameters=list(g=2,Bmax=10^5,tmax=10) # time in days

# Initial conditions Bini=c(B=1)

# Run simulation time.points = seq(0, parameters$tmax, parameters$tmax/100) # timepoints for output Bsolution=ode(y=Bini, time=time.points, logistic.model, parms=parameters)

# plot timecourse of infection # 1st plot with number on y axis plot(Bsolution[,1],Bsolution[,2], ylim=c(0,2*10^5), log="", type="l", xlab="Time (days)",

3 predator−prey model predator−prey model

Prey 25 50 Prey Predator 25 50

Predator 20 40 20 40 15 30 15 30 number Predator 10 20 number Predator 10 20 5 10 5 10 0 0 0 0 0 10 20 30 40 50 0 10 20 30 40 50 0 10 20 30 40 50 0 10 20 30 40 50 time (years) Prey time (years) Addition immunePrey response to What is the eect of changing the initial conditions? What is the eect of changing the initial conditions? bacteria growth model What will be the eect of introducing a carrying capacity to prey? How will it change the steady states? What will be the eect of introducing a carrying capacity to prey? How will it change the steady states? dB B bacteriapreydB = gBB(1 ) kBI prey = gBdt(1 )≠ BkBImax ≠ dt ≠ B ≠ maxdI predatordI = rBI dI predatorimmune = rBIdt dI ≠ response dt ≠ require(deSolve) kBI require(deSolve) # the equations for the predator-prey model area here dI # the equations for the predator-prey model area here pp.model2 <- function(t, y, parms) { pp.model2 <- function(t, y, parms) { with(as.list(c(y,parms)), # allows you to refer to parameters and state variables by name with(as.list(c(y,parms)), # allows you to refer to parameters and state variablesrBI by name { gB(1-B/Bmax) { Bacteria, B Immune Response, I dB = g*B*(dB =1-B/Bmax)g*B*(1-B/Bmax) - k*B*I -#k*B*I prey # prey dI = r*B*IdI = -r*B*Id*I -#d*I predators# predators dy=c(dB,dy= dI)c(dB, dI) return(returnlist(dy))(list(dy)) }) }) } }

#model#model parameters parameters parameters=parameters=list(g=list2,k=(0.5g=2,,r=k=0.50.5/,3r=,d=0.50.6/3,,Bmax=d=0.640, )Bmax=40)

# initial# initial conditions conditions init.cond=init.cond=c(B=.1,cI=(B=.1.)1,I=.1) #Time#Time points points to run to the run simulation the simulation tmax=50tmax=50 npoints=npoints=1000 1000

7 7