Jump to content

Talk:Evolutionary algorithm: Difference between revisions

→‎Problem in previous Python implementation: use syntaxhighlight tags instead of lang
(→‎Problem in previous Python implementation: use syntaxhighlight tags instead of lang)
Line 78:
== Problem in previous Python implementation ==
In the first Python example:
<langsyntaxhighlight Pythonlang="python">def mutaterate():
'Less mutation the closer the fit of the parent'
#This formula does not work as intended because it performs int division
return 1-((perfectfitness - fitness(parent)) / perfectfitness * (1 - minmutaterate))</lang>
</syntaxhighlight>
For ex- ((20 - 10)/20*(1-0.09)) will evaluate to 0
Thus it gets stuck in an infinite loop waiting for mutation to occur.
3,045

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.