RosettaCodeData/Task/Evolutionary-algorithm/0DESCRIPTION

14 lines
1.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Starting with:
* The <code>target</code> string: <code>"METHINKS IT IS LIKE A WEASEL"</code>.
* An array of random characters chosen from the set of upper-case letters together with the space, and of the same length as the target string. (Call it the <code>parent</code>).
* A <code>fitness</code> function that computes the closeness of its argument to the target string.
* A <code>mutate</code> function that given a string and a mutation rate returns a copy of the string, with some characters probably mutated.
* While the <code>parent</code> is not yet the <code>target</code>:
:* copy the <code>parent</code> C times, each time allowing some random probability that another character might be substituted using <code>mutate</code>.
:* Assess the <code>fitness</code> of the parent and all the copies to the <code>target</code> and make the most fit string the new <code>parent</code>, discarding the others.
:* repeat until the parent converges, (hopefully), to the target.
Cf: [[wp:Weasel_program#Weasel_algorithm|Weasel algorithm]] and [[wp:Evolutionary algorithm|Evolutionary algorithm]]
<small>Note: to aid comparison, try and ensure the variables and functions mentioned in the task description appear in solutions</small>