The only part of this function differring from my previous functional one is adding a variable to be calculated in each generation.
NDeme=0.5(Nmax+Nmin)+0.5(Nmax+Nmin)*sin(2pi*t/period)
#period=12 genetation in setting
#oscillating population size
As NDeme can be 0 at 9th (9+12n) generation, I set 0 to be replaced by 1 for avoiding NaNs, so it gets the normal output at 9th and move on to error in 22th generation. The end of the shared matrix of the deme in 21th generation doesn’t contain any NaNs.
generation############21
deme#####5
nan in x CartesianIndex{2}[] #beginning of this turn
nan in x_end of nDemes loop CartesianIndex{2}[] #end of this turn
#observation: no NaNs contained)
However, the extracted matrix at the beginnig of 22th generation contains NaNs in the column corresponding to the 21st generation.
generation############22
#deme1 to 4 are all fine.
deme#####5
nan in x CartesianIndex{2}[CartesianIndex(3, 21), CartesianIndex(4, 21), CartesianIndex(5, 21), CartesianIndex(6, 21), CartesianIndex(7, 21), CartesianIndex(8, 21), CartesianIndex(9, 21), CartesianIndex(10, 21), CartesianIndex(11, 21), CartesianIndex(12, 21), CartesianIndex(13, 21), CartesianIndex(14, 21), CartesianIndex(15, 21), CartesianIndex(16, 21), CartesianIndex(17, 21), CartesianIndex(18, 21),
CartesianIndex(19, 21), CartesianIndex(20, 21)]
#all NaN in the column corresponding to 21th generation
x [0.0, 0.0, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN]
I reboost my laptop and atom several times but problem remains. The error information: often in 10th generation, and sometimes 22th, 34th which are the time points when NDeme supposed to be zero but set to 1.
I got confused by the converse testification between outputs in last generation and input in this generation. Could anyone give a hint? Is this the problem of algorithm (the variable, or replacing 0 with 1) or else(some unknown setting)?