MadonnaModel
Arial!D(.2>
B6: *{Figure 6}
{Information flow in a modified small-world network}
{simulation control parameters}
METHOD RK4
STARTTIME = 0
STOPTIME=30
DT = 0.10
begin = 1
end = 4 {variable that holds how many populations are in the model, change when needed}
net_end = end^2
{birth, death, and migration constants}
outmig_constant = .10
birth_rate = 0.02
death_rate = 0.02
{initialize population, and limit population to non-zero values}
limit pop >= 0
init pop[begin..end,begin..end] = #pop(j,i)
{this section contains internal index variables needed for managing arrays of flows from one location to another -- these do not need to be modified by the user}
ref_table[begin..end,begin..end] = IF(i = 1) THEN j
ELSE
ref_table[i -1, j] + end
temp_rev[begin..end,begin..end] = i*10 + j
rev_table[begin..end^2] = temp_rev[1,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]
{This initializes the network for each population}
network[begin..net_end, begin..net_end] = #network(i,j)
{This block counts the number of populations in the given populations network list and stores it in network_count}
temp[begin..net_end, begin..net_end] = IF (network[i,j] = 1 and j > 1) THEN
temp[i,j-1] + 1
ELSE IF (network[i,j] = 1) THEN
1
ELSE IF (network[i,j] = 0) AND (j > 1) THEN
temp[i,j-1]
ELSE
0
network_count[begin..end^2] = temp[i,net_end]
{This uses the same method as the network_count code but this is used to calculate all the populations that have this current population on thier network list. If they are on the network list then then will get an additional outmigration term added on to the running total}
inmigration_temp[begin..net_end, begin..net_end] = IF (network[i,j] = 1 and j > 1) THEN
inmigration_temp[i,j-1] + outmigration_pop[INT(rev_table[j]/10),MOD(rev_table[j],10)]
ELSE IF (network[i,j] = 1) THEN
outmigration_pop[INT(rev_table[j]/10),MOD(rev_table[j],10)]
ELSE IF (network[i,j] = 0) AND (j > 1) THEN
inmigration_temp[i,j-1]
ELSE
0
{this piece of code converts the inmigration_temp [end X end] array into a 2-dimensional [begin X end] size array}
temp2[begin..end^2] = inmigration_temp[i,net_end]
inmigration_pop[begin..end, begin..end] = temp2[i + end*(j-1)]
{This takes the current population, multiplies it by the outmig_constant then it checks to see how many populations are on its network list and divides by that number}
outmigration_pop[begin..end, begin..end] = (outmig_constant*pop[i,j]) /network_count[ref_table[i,j]]+qYM#network""?@@@@@@@AA A0A@APA`ApAA????@???@@?@?@???@?????@?????A?A? A?????0A?????@A???PA?`A?pA???A???U,},>#pop
?@@@@? A A@@@@ A A>>@>@i@rk4 MbP?MbP?MbP?
(4X\` &0,Fr.Fjnr
z,%,@v+++@M, -,$eB&mB(uB*}B,@.@B