Hi,

Am Freitag, 6. April 2012 11:33:25 UTC+2 schrieb Goldritter:
>
> I am a littlebit puzzeled about the chosen structure. 
> First we have the functions for the algorithm and the agents which 
> performs the function. There are the creator agents in the domicilems, 
> which adds new tested individuals into the populatin. Then the grimreaper 
> which removes individuals from the population and at last the 
> start-stop-agent which "controls" the process.
> But this agent has only one status,


actually it has two states: "stopped" and "running" in the original (funny, 
how this English terms ended up in the book ;-). 
 

> which is not stet by any function which is send to the agent.


I probably don't understand, what you mean by this, but the state of an 
agent is always changed by sending functions.  In the code of your first 
post that's done with:

  ;; in start-evolution
  (send start-stop-agent (constantly "running")) 
  ;; ... in stop-evolution
  (send start-stop-agent (constantly "stopped"))

 

> The status is set by the function start-evolution and by track-evolution.
> Would it be more idomatic and correct to set the conditions when the 
> algorithm should finish during 'prepare-evolution' or as a parameter in 
> 'start-evolution' instead in 'track-evolution' which is normal only a 
> function to log the sideeffects during the algorithm runtime?
>

If you are striving for a generic and reusable library function which will 
perform the genetic algorithm transparently, your approach would be more 
idiomatic, at least more 'functional'.  In that case, however, one would 
also want to make the backend functions (fitness calculation, creation of 
individuals etc) configurable.

For the book we needed to create some code, which shows the things that 
were introduced in the chapter and which produces some output suitable to 
be printed.
 

> What would the better way to give the 'start-stop-agents' more control 
> over the algorithm?
>

This agent represents the state 'is the algorithm finished, yet'.  This 
state needs to be shared among threads and is mainly used to decide whether 
the agents doing all the population processing should resend their update 
function to themselves. The decision is made in the function 
track-evolution:

  (when (= 0 (second (first best))) 
          (stop-evolution)) 

Thus, the monitoring thread-- which is creating the output, too-- figures 
out when to stop the 'network' of running agents.  It tells the network by 
updating the appropriate agent.  (BTW compare that approach to the one in 
function 'bifurkation' in section 4.3 where the end of the calculation is 
not detected but the Timer object is stopped after 5 seconds.)

I hope, this helps.  In any case, it's rather cool to see someone playing 
around with that piece of code so much.  That's what examples are all 
about, right? :-)


Kind regards,
Stefan

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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

Reply via email to