Hmm. Starting to get it, I think. I now just made a small number of
agents, and gave them one function (do-a-years-worth-of-simulations)
to compute each. However, that didn't fool them either (still only
uses 1 processor), while passing two agents a fibonnaci function does
get both processors running.
I'll try another scheme, but comments to steer me onto the right path
are welcome ;).
(defn inc-year
[_]
(dosync (commute year inc)))
(defn do-year
"Calculate one year"
[_]
(dosync
(send (agent nil) inc-year)
(dotimes i popsize
(doseq a [evolve birth evolve infect evolve death evolve
infect evolve]
(a i)))))
(setup)
(time
(do
(dotimes y 25
(def proc1 (agent nil))
(def proc2 (agent nil))
(send-off proc1 do-year)
(send-off proc2 do-year)
(await proc1 proc2))
(report)))
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---