simoncarrignon / mixed-transmission

GNU General Public License v3.0
1 stars 0 forks source link

General structure test - big list of small array VS small list of big arrays. #2

Closed simoncarrignon closed 10 months ago

simoncarrignon commented 11 months ago

So far the algorithm relies on a list of size N where each elements of the list is of size 7 and contain mix of tables/booleans/characters (in a full ABM way) . It would probably more efficient if the list was of size 7 and and each of these 7 elements would be array/matrix of size NxM, where m would depend on the size of each given properties. This would allow to compute all properties as vector in a much faster way ; but it means that each of the 7 NxM array will have to be increased at each birth (that's what I did in : https://framagit.org/sc/twitter-spread/ and : framagit.org/sc/pleistoclimate ). I have no idea what's the best trade-off and probably will simply try both option and see what's the fastest (fastest whcih will probably also depend on how fast pop are growing etc...)

simoncarrignon commented 11 months ago

maybe need to find way to implement social learning/transmission that is independent of the choice of this part of implementation ; and allow parallel works.

simoncarrignon commented 10 months ago

R/ modelVector.R : implement another version of the main structure of the model based on arrays. Obviously way faster:

image

The results are very similar, althought I found case where they were not ; but probably because of the order of marriage/reproduction/death being not the same in the vector vs list version (in the list version you can get married, give birth then die in a same year while your partner doesnt. This doesn´t happend with the array solution as everyone get updated at the same time

test

I still want need to explore a bit the parameters, It may happen than in some case the list would be better but so far it looks very unlikely wrt to the 20time spead increase. I will still keep the list version in a side, maybe useful later on.

simoncarrignon commented 10 months ago

Closing that, final decision/structure is arrays as much as possible!