! Patch Selection Model -- True BASIC version ! Clark, C.W. & M. Mangel. 1999. Dynamic State Variable Models in Ecology: ! Methods and Applications. Oxford University Press. !This is the Patch Selection Model from Chapter 1 dim f(0 to 30, 1 to 20), v(3,0 to 30, 1 to 20),d(0 to 30, 1 to 20) dim m(3),p(3),a(3),y(3),c(3) call parameters call end_condition call solve_dpe sub parameters let x_crit=5 let x_max=30 let t_max=20 let x_rep=4 print "Parameters are these:" print "x_crit = ";x_crit;" x-max = ";x_max;" t-max = ";t_max;" x-rep = ";x_rep !read the parameters for the three patches !form of the data is m,p,a,y print "patch","m","p","a","y" data .01,.2,1,2 data .05,.5,1,4 for i=1 to 2 read mm,pp,aa,yy let m(i)=mm let p(i)=pp let a(i)=aa let y(i)=yy print i,m(i),p(i),a(i),y(i) next i !parameters for patch 3 !form of data is m,a,c data .02,1,4 read mm,aa,cc let m(3)=mm let a(3)=aa let c(3)=cc end sub sub end_condition let acap=60 let x_0=.25*x_max print print "x","F(x,T)" for x=x_crit to x_max let f(x,t_max)= acap*(x-x_crit)/(x-x_crit+ x_0) print x,f(x,t_max) next x !also set the boundary condition that F(x_crit,t)=0 for t=1 to t_max-1 let f(x_crit,t)=0 next t input prompt "hit any key to go on":k$ end sub sub solve_dpe print for t=t_max-1 to 1 step -1 print print"t";tab(10);"x";tab(20);"F(x,t)";tab(30);"d(x,t)";tab(40);"V(1,x,t)"; tab(50);"V(2,x,t)";tab(60);"V(3,x,t)" for x=x_crit+1 to x_max for i=1 to 3 !find the fitness values in each patch if i=1 or i=2 then !foraging patch let xp=x - a(i) + y(i) let xp = min(xp,x_max) let xpp = x-a(i) let xpp = max(xpp,x_crit) let v(i,x,t) = (1-m(i))*(p(i)*f(xp,t+1) +(1-p(i))*f(xpp,t+1)) else !reproductive patch if x