I've written individual-based models using agents, and using refs. Currently my decision tree is 'agents, if there are no events which need to be atomically synchronized between individuals**'.
In both cases I had a vector full of individuals called 'world'. When the individuals were agents, I could do (doseq [a (shuffle world) , e (shuffle [birth death infect infect evolve])] (send a e)) (apply await world) to get things concurrent. In the case of refs, I split the world with (partition) into 4 parts and make them concurrent with futures (I've 4 processors in this computer), and loop over that. bigfun (comp retire-host slowdown-host infect-hosts naturalrecovery- host pair-host) proc1 (future (doseq [i (subvec world 0 2499)] (bigfun i))) proc2 (future (doseq [i (subvec world 2500 4999)] (bigfun i))) proc3 (future (doseq [i (subvec world 5000 7499)] (bigfun i))) proc4 (future (doseq [i (subvec world 7500 9999)] (bigfun i)))] (map deref (list proc1 proc2 proc3 proc4))))) Hope that helps! ** the action that required me to use refs was that hosts should only be partnered with exactly 1 other host. I had to avoid that two hosts were succeeding to partner with the same host, because from their point of view, that host had no partner still. On Apr 17, 12:03 am, Raoul Duke <rao...@gmail.com> wrote: > >> How do you decide which construct to use for a particular algorithm/ > >> program? > > it would be nifty keen nice if there were some cute visual flow charty > representation of people's decision tree? maybe something that can get > 'crowd sourced' on some wiki page somewhere. some day. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---