Sorry for not testing before posting, but in this code:

 (define (randomise-over-fitness accumulated-payoff-percentage population speed)
  (for/list ([n (in-range speed)])
    [define r (random)]
    (for/and ([p (in-list population)]
              [a (in-list accumulated-payoff-percentage)]
              #:break (< r a))
      p)))

It looks like the population is stored in a list, and the changes in
the populations create more lists. I think that changing the
implementation to use vectors instead of list would make the code
faster. (But I haven't tested it.)

Also, I think that for/and can be changed to for/last. I guess it will
almost no no change the speed, but it would make the intention
clearer.

Gustavo



On Mon, Oct 12, 2015 at 5:31 AM, Linh Chi Nguyen
<nguyenlinhch...@gmail.com> wrote:
> I dont know how the email group work. If someone keeps receiving emails out 
> of interest, please notice me.
>
> Thanks Bryan for the suggestion, it's nice to know, however Im not able to 
> afford upgrading now.
>
> And Matthias, for your notice of the spawning process
> ```
> (define (randomise-over-fitness accumulated-payoff-percentage population 
> speed)
>   (for/list ([n (in-range speed)])
>     [define r (random)] ;; SHOULDN"T THIS LINE BE OUTSIDE OF THE for/list 
> COMPREHENSION?
>     (for/and ([p (in-list population)][a (in-list 
> accumulated-payoff-percentage)]
>                                       #:break (< r a))
>       p)))
> ```
>
> The randomly generated r has to be inside the for/list loop. Because if it's 
> outside, then there is only one random number generated at the beginning, and 
> the newly spawn automata will keep being the same one repeatedly.
>
> For example, when the learning speed is s = 10, it means that, 10 old 
> automata should be replaced with 10 new ones. And the replacement should be 
> done in 10 different places in the population.
>
> This procedure is called an independent bernoulli draw. We independently draw 
> a random number (associated with an automaton) for 10 times. How likely an 
> automaton is chosen depends on its own fitness (its interval in the unit 
> scale of the accumulated percentages.)
>
> On Monday, 12 October 2015 03:46:05 UTC+2, Matthias Felleisen  wrote:
>> I have pushed some more cleanups, more speed.
>> I added another question to the “spawning” procedure.
>>
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to