So, basically, I have a code for python 2.7 like this:
femalebreeders = [[[0] * 4] * n] * pat
femalebreeders1 = [[[0] * 4] * n] * pat
for y in range(pat):
for x in range(n):
Indivmales[y][x] = malebreeders[y][x][0] + malebreeders[y][x][3]
Fec1[y] = 1 - c * numpy.array(numpy.mean(Indivmales[y]))
FecMales = numpy.ndarray.tolist(1 + (numpy.array(Indivmales) * b) - (numpy.array(Indivmales) * u))
Fec = [0 if i < 0 else i for i in Fec1]
FecPop = numpy.mean(Fec)
FecCalcF[y] = (Fec[y] * (1 - mf)) / ((Fec[y] * (1 - mf)) + (FecPop * mf))
FecCalcF2[y] = (Fec[y] * mf) / FecPop
FecCalcM[y] = (Fec[y] * (1 - mm)) / ((Fec[y] * (1 - mm)) + (FecPop * mm))
FecCalcM2[y] = (Fec[y] * mm) / FecPop
for x in range(n):
for y in range(pat):
if random.random() < FecCalcF[y]:
z = y
else:
z = numpy.random.choice(pat, p=numpy.ndarray.tolist(numpy.array(FecCalcF2)/sum(FecCalcF2)))
f = random.randrange(n)
m = random.randrange(n)
if random.random() < mut:
if random.random() < 0.5:
femalebreeders1[y][x][0] = femalebreeders[z][f][0] + \
random.uniform(-1, 1)
Some background. n is number of individuals, pat is the number of patches where individuals are. FecCalcF and FecCalcF2 are just variables that say if individuals are going to migrate or not (let's assume that they always migrate to a new patch). So, I want to, for every individual, assign it a patch (y). And, because they always migrate, their parents come from another patch (z) and that depends on the fecundity of the individuals on each patch. In the end, I want to have different females that came from different patches. However, the values of the femalebreeders is something like ([0.10, 0, 0, 0], [0.10, 0, 0, 0] .... ]. Basically, the first value is always equal for all of them (and the same for the others values, I'm just showing part of it). Basically, it seems that the code gives them always the same value - which means that the parents are all the same and all from the same patch. Anyone knows what I'm doing wrong?