Home > Uncategorized > Genetic algorithims in C#

Genetic algorithims in C#

Genetic algorithms are basically where random operations are applied to solve problems, and the ‘fittest’ of these random collections bias the generation of the next collection of random operations.

The beauty of this, is that there is no need to understand the underlying problem, just throw lots of computing power at it, until the solution is approximated.

This is the same way that nature uses to solve problems, where random organic mutations discover the best, or at least a suitable, creature for any hospitable environment. However, that doesn’t need to be the basis for computer algorithms.

For example, let’s take a set (x) of 5 (n) numbers [1,2,3,4,5], what comes next? 6?, yes, pretty obvious, but how would a computer solve that?  x[n-1]+1, is the solution if you understand the sequence, but if you didn’t….

Let’s say our objects can be x[1],x[2]…x[n], and the whole numbers 1 to n, then we have 5 basic operations, +, -, /, *, %, and we put our operation complexity (c) to 3, for instance.

Pick c random operations, between the range of 1 to n*2, followed by c-1 random operations in the range 1 to 5, this gives us a "bytecode" sequence of
which gives
x[5] % x[4] / 10  =  0.1

Nowehere near 6, but lets say we kept randomly doing that until we got the number 6. From this we then create a "population" of similar algorithms, by just
tweaking one digit of the byte code up or down, or replacing an operation.

Then the logic goes, we change the sequence [2,3,4,5,6] with the next number being 7, and the closest of the "population" goes on to create the next generation.

What I’ve described above is akin to Asexual reproduction in nature, where the genetic code of any organism is inherited from one parent only. This is only used for simple organisms in nature, and it is more normal for genetic code to be inherited from two parents.

To apply this analogy to the code, it would mean that the two closest operations, i.e. resulting in 6.03 and 5.98 in the first generation would have their byte-code merged, either by averaging, or substitution.

To extend this analogy beyond nature, it would be quite possible, to take the top 3 fittest operations, and merge them, resulting in trisexual reproduction, although evidence could only be garnered from experimentation at this point, it would stand to reason that if 2 parent genetic inheritance is more effective than single parent inheritance at creating advanced life, perhaps the same can be applied to genetic algorithms?

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: