Ok.. seems like the short lifespan of the agent-threads makes it hard
for the program
to actually start using its (in this case 2) multiple cpu's.
The next program has no problem filling both cpu's together for 199%
(top, linux), whilst the simulation
has trouble getting above 110%, but occasionally jumps higher to up to
199%.
I'll go and build a version in which the agents are kept alive and
useful longer.
(defn fib [n] (reduce * (range 2 (inc n))))
(defn doublesend
[]
(do
(def myagent (agent 100000))
(def myagent2 (agent 100000))
(send-off myagent fib)
(send-off myagent2 fib)
))
(doublesend)
On Dec 14, 3:07 pm, bOR_ <[email protected]> wrote:
> The order doesn't matter, and a somewhat mixed order would even be a
> welcome side-effect of the whole concurrency bit.
>
> What does worry me is that the agents are very short-lived. The
> longest of these tasks takes 0.5msec (any evolution event), so I am
> not sure if spawning all these agents is worth the overhead.
>
> There are several other possibilities: I could have each place in the
> world be a single agent, which just continuously cycles through the
> events, even if there is
> no host occupying the place. I could also tie hosts to agents (which I
> think is somewhat like ant.clj does). Will look into it.
>
> On Dec 14, 2:55 pm, Chouser <[email protected]> wrote:
>
> > On Sun, Dec 14, 2008 at 8:49 AM, bOR_ <[email protected]> wrote:
>
> > > Thanks! Needed only a small change then :)
>
> > > (time
> > > (do
> > > (dotimes i popsize
> > > (doseq a [birth death infect infect evolve evolve evolve
> > > evolve evolve]
> > > (send-off (agent i) a)))
> > > (dosync (commute year inc))))
> > > (report)
>
> > Note that you've now got popsize*9 agents, and the actions in your
> > vector are not guaranteed to happen in order for any given 'i' -- I
> > don't know if that matters to you or not.
>
> > --Chouser
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---