MRC-CSO-SPHSU / LoneParentsModel.jl

An initial implementation of an ABM for social and child care
0 stars 5 forks source link

factor out iteration in model functions #74

Closed mhinsch closed 2 years ago

mhinsch commented 2 years ago

Not important now, but in the medium term it would be good to split model functions into the iteration part, that picks the agents to be modified and the actual modification that operates on single agents. E.g. (simplified example):

function doAgeTransitions!(people, model, pars)
    for p in people
        ageTransition!(p, pars)
    end
end

function ageTransition!(person, pars)
     # all the important bits go here
end

That makes the model easier to read and modify (IMO) and would be needed anyway if we ever want to do an event-based version.

AtiyahElsheikh commented 2 years ago

Just remind me if I do a pull request that does not follow this pattern

AtiyahElsheikh commented 2 years ago

Question: You mentioned that the operatorinis slow. Here it is used.

mhinsch commented 2 years ago

I maybe said that in a misleading way. in itself isn't slow, but IIRC you used it to check whether an object was element of a collection. It's easy to forget that in simply iterates the vector until the element is found, so that check was a very slow operation.