<div dir="ltr"><div>Hello All,</div><div><br></div><div>As part of the design for a simple genetic algorithm I have this function:</div><div><br></div><div><div>(define (roulette-wheel-ratio generation-fitness ) </div><div>
(cond [(empty? generation-fitness) empty]</div><div> [else (cons (/ (first generation-fitness)</div><div> (total-population-fitness generation-fitness)) </div><div> (roulette-wheel-ratio (rest generation-fitness)))]))</div>
</div><div><br></div><div>where generation-fitness is a list of values that correspond to the fitness of each individual in a population. For example, in a generation with population size 12, generation fitness may look like:</div>
<div><br></div><div><div>'(7.8807275269175125</div><div> 6.78896220864992</div><div> 6.52572681075793</div><div> 3.208263473483078</div><div> 9.970710802683316</div><div> 10.400703374724888</div><div> 7.434703353949041</div>
<div> 6.009574612909729</div><div> 2.9503066173989634</div><div> 6.07124467626777</div><div> 2.1893449585751754</div><div> 1.0741024515301607)</div></div><div> </div><div>Here is how I have defined the auxiliary function, total-population-fitness:</div>
<br clear="all"><div><div>(define (total-population-fitness generation-fitness)</div><div> (foldl + 0 generation-fitness))</div></div><div><br></div><div><div>I was wondering how can I modify the above function, roulette-wheel-ratio so that when it evaluates the helper function, total-population-fitness it only does so for the initial list of generation-fitness. Otherwise the total population fitness decreases for each recursive call which is what I don't want, it should remain constant throughout the entire function call.</div>
<div><br></div><div>Basically, is it possible to modify this function so that the auxiliary function call (total-population-fitness generation-fitness) remains unaffected by the natural recursion imposed by roulette-wheel-ratio? </div>
<div><br></div></div><div><div>Any help would be appreciated as I am still learning the Racket basics.</div></div><div><br></div><div>Kind Regards,</div>-- <br>Rian Shams
</div>