The Azimuth Project Experiments in predator-prey with Sage (Rev #10, changes)

Showing changes from revision #9 to #10: Added | Removed | Changed

Contents

Idea

Showing I want to showing an easy way of doing predator-prey modeling inSage . Right now it is a generic dimensionless version and one version which is the competitiveLotka-Volterra.

Details

Original Lotka-Volterra

This is the original Lotka-Volterra phase map for a non-dimensional form. This was posted on Marshall Hampon on the []ask.sagemath.org](http://ask.sakemath.org) site. The original Lotka-Volterra equations has many coarse “flaws” and has also been modified over time as we’ll see below. Dimensionless format of Lotka-Volterra. The default for Sage ode_solver() is to useask.sagemath.org site. The original Lotka-Volterra equations has many coarse “flaws” and has also been modified over time as we’ll see below. Dimensionless format of Lotka-Volterra. The default for Sage ode_solver() is to use runga-kutta-felhberg (4,5) to find solutions

Plot and Code

T = ode_solver()
T.function = lambda t, y: [y[0]-y[0]*y[1], -y[1]+y[0]*y[1]]
sol_lines = Graphics()
for i in srange(0.1,1.1,.1):
T.ode_solve(y_0=
[i,i],t_span=[0,10],num_points=1000)
y = T.solution
sol_lines += line([x[1] for x in y], rgbcolor = (i,0,1-i))
show(sol_lines+point((1,1),rgbcolor=(0,0,0)), figsize = [6,6], xmax = 6, ymax = 6)


This is the phase plot for prey on the x-axis and predator on the y-axis.

Interactive and more realistic Lotka-Volterra

Here we enable choice of the exponential growth in the original Lotka-Volterra and logistic growth. We also first added add a parameter g which is used in both and k which is the scaled to carrying control capacity. the effect of the growth of the number of predator. For g=1 I got a similar plot as the first one above.

See if you can find the fixed point for the latter (using the code below)?

def lv(g,k=None):
Tg = ode_solver()
Tg.function = lambda t, y: [y[0]*(1 - y[1]), -g*y[1] + y[0]*y[1]]
sol_lines = Graphics()
for i in srange(0.1,1.1,.2):
Tg.ode_solve(y_0=[i,i],t_span=[0,10],num_points=10^3)
y = Tg.solution
sol_lines += line([x[1] for x in y], rgbcolor = (i,i,0))
return sol_lines

@interact
def lv_explorer(gamma = (0.,1.,0.1)):
#html("equilibrium points are is %.2f" % k)
show(lv(gamma))


It Try should to look see like this:what happens for small values of g. Also see if you can find a way to show time plots for predator and prey in the same plot.

def lv(g,k,growth):
Tg = ode_solver()
if growth == "Malthusian":
Tg.function = lambda t, y: [g*y[0]*(1-y[1]), (-1.0/g)*(1-y[0])]
else:
Tg.function = lambda t, y: [g*y[0]*(1-y[0]/k - y[1]), (-1.0/g)*(1-y[0])]
sol_lines = Graphics()
for i in srange(0.1,1.1,.2):
Tg.ode_solve(y_0=[i,i],t_span=[0,10],num_points=1000)
y = Tg.solution
sol_lines += line([x[1] for x in y], rgbcolor = (i,0,1-i))
return sol_lines

@interact
def _(g = (0.1,1.,0.1), k = (0.1,4.0,0.1), Growth=["Malthusian","Logistic"]):
show(lv(g,k,Growth),legend_label='Lv')


Next step

We will add some better model of growth and look at cases where Lotka-Volterra might lead toHopf bifurcation and also see if we can add the Allee effect.

References

category: experiments