MadonnaModel
Arial!D(.2>
B6:
y
aH{Model 1b: Moore neighborhood model for material quantitites}
METHOD RK4
STARTTIME = 0
STOPTIME=100
DT = 0.01
{begin should not be changd, end will determine how many populations you have by a power of 2, so if end is 3 then you will have 9 populations in a square grid
1 4 7
2 5 8
3 6 9}
begin = 1
end = 3
{constant percentage that will migrate out of each population}
outmig_constant = .10
birth_rate = 0.02
death_rate = 0.02
{These constants determine how to divide up the out_migration population amoung the popuations they will migrate too
corner populations can migrate to only 3 possible popualations, edge pops have 5 populations, etc...}
moore_corner = 1/3
moore_edge = 1/5
moore_center = 1/8
{Define Populations}
limit pop >= 0
{This initialization can be used to determine the starting # in each population}
init pop[begin..end,begin..end] = #import_1b(j,i)
{Caculate the birth and death rates for each population.}
br_pop[begin..end,begin..end] = birth_rate*pop[i,j]
dr_pop[begin..end,begin..end] = death_rate*pop[i,j]
{Population totals}
{d/dt(pop[begin..end,begin..end]) = br_pop[i,j] - dr_pop[i,j] + inmigration_pop[i,j] - outmigration_pop[i,j]}
d/dt(pop[begin..end,begin..end]) = IF((i = begin OR i = end) AND (j = begin OR j = end)) THEN
br_pop[i,j] - dr_pop[i,j] + inmigration_pop[i,j] - outmigration_pop[i,j]*(1/moore_corner)
ELSE IF (i = begin OR i = end OR j = begin OR j = end) THEN
br_pop[i,j] - dr_pop[i,j] + inmigration_pop[i,j] - outmigration_pop[i,j]*(1/moore_edge)
ELSE
br_pop[i,j] - dr_pop[i,j] + inmigration_pop[i,j] - outmigration_pop[i,j]*(1/moore_center)
{The inmigration takes into consideration the Moore neighborhood model where migrations occur between populations to the direct in all directions of current populations.
This 4 IF statment's first takes into consideration the 4 corners. If its a corner population then there are only 3 possible populations that can interact with it (EX: pop1 can only interact with pop2 & pop4 & pop5)
The next 4 IF statements will take into consideration if its not a corner population but a population that lies along the edge of the grid. In this case there are only 5 possible interactions (EX: pop2 can only interact with pop1 & pop3 & pop5 & pop4 & pop6.
Then finally if its not a corner and does not lie on the edge then it can interact will all 8 surrounding populations}
inmigration_pop[begin..end,begin..end] = IF ((i = begin) AND (j = begin)) THEN
outmigration_pop[i,j+1] + outmigration_pop[i+1,j] + outmigration_pop[i+1,j+1]
ELSE IF ((i = begin) AND (j = end)) THEN
outmigration_pop[i,j-1] + outmigration_pop[i+1,j] + outmigration_pop[i+1,j-1]
ELSE IF ((i = end) AND (j = end)) THEN
outmigration_pop[i,j-1] + outmigration_pop[i-1,j] + outmigration_pop[i-1,j-1]
ELSE IF ((i = end) AND (j = begin)) THEN
outmigration_pop[i,j+1] + outmigration_pop[i-1,j] + outmigration_pop[i-1,j+1]
ELSE IF (i-1 < begin) THEN
outmigration_pop[i,j+1] + outmigration_pop[i,j-1] + outmigration_pop[i+1,j] + outmigration_pop[i+1,j+1] + outmigration_pop[i+1,j-1]
ELSE IF (i+1 > end) THEN
outmigration_pop[i,j+1] + outmigration_pop[i,j-1] + outmigration_pop[i-1,j] + outmigration_pop[i-1,j+1] + outmigration_pop[i-1,j-1]
ELSE IF (j-1 < begin) THEN
outmigration_pop[i+1,j] + outmigration_pop[i-1,j] + outmigration_pop[i,j+1] + outmigration_pop[i+1,j+1] + outmigration_pop[i-1,j+1]
ELSE IF (j+1 > end) THEN
outmigration_pop[i+1,j] + outmigration_pop[i-1,j] + outmigration_pop[i,j-1] + outmigration_pop[i+1,j-1] + outmigration_pop[i-1,j-1]
ELSE
outmigration_pop[i+1,j] + outmigration_pop[i-1,j] + outmigration_pop[i,j+1] + outmigration_pop[i,j-1] + outmigration_pop[i+1,j+1] + outmigration_pop[i+1,j-1] + outmigration_pop[i-1,j+1] +outmigration_pop[i-1,j-1]
{This first determines if the population is a corner, edge or center population. Then depending on what it is, the outmigration will be calculated by its taking a percentage (outmig_constant) of its current population and dividing that by the number of populations it will be sharing with. So for example, pop1 = 100 and it shares it popuations will its Moore neighbors pop2, pop4, pop5. so it will be (100 * .10) / 3 so the result will be 3, which means that 3 people will go to pop2, 3 will go to pop4 and 3 will go to pop5}
outmigration_pop[begin..end,begin..end] = IF((i = begin OR i = end) AND (j = begin OR j = end)) THEN
pop[i,j]*outmig_constant*moore_corner
ELSE IF (i = begin OR i = end OR j = begin OR j = end) THEN
pop[i,j]*outmig_constant*moore_edge
ELSE
pop[i,j]*outmig_constant*moore_centerI5 A#import_data?@@@?@@@@@ AB@@@A@@JUJaK#import_1b?@@@?B@@@KKLiKL}@rk4DT?MbP?MbP?MbP?&6
:Bfjn 2&>,T.!Fjnr
zIIAMvIIIMJ I$N&N(N*N,%M.9MN