This is a very simple GA written mostly in GC script and using a predominantly model based problem to try and improve.
NB it does require the NPtools1.03.cs function library to be loaded before it will run as it uses some of those extra functions to improve readability of the code.
Basic Genetic Algorithm Source Code
Genetic algorithms are a heuristic method of finding plausable solutions to a well defined problem. They are useful for searching for solutions to problems that are susceptible to becoming trapped in local optima.
Wikipedia link to genetic algorithms
It's important to make the distinction between the process of improvement, and the best possible result.
Algorithms like this one simply provide a 'better' solution, sometimes much better, but it is very unlikely to find the ultimate optima from a particular solution space.
This is a very simple example of a genetic algorithm, it copies John Holland's initial suggestions from the book “adaptation in natural and artificial systems” almost exactly.
This is a replication of an earlier program that was written that relied heavily on GCscript functions that had been programmed in C#. This version was never satisfactorily debugged, and so this version was written mostly in pure GCscript.
There is a collection of GCscript functions that are used throughout the actual running of the GA that could quite conceivably be rewritten as C# functions to streamline the running of the code, but at the moment the ease of debugging provided by interpreted code outweighs this.
This creates all the functions, and all the geometric model/problem/base phenotype to be explored.
You should always roll back to this transaction before making changes to the parameters or the changes will be recorder after the GA runs, which will have no effect on the GA!
In order to check that the GA is actually search method that is worthwhile, this script transaction exercises the model randomly for a specified number of times to set a benchmark level of fitness to try and outperform. This is displayed as a grey line in the fitness graph. Hopefully the final solution will be above this line.
This script transaction runs the whole GA based on the variables set up in the first transacton.
It first creates a population of solutions, and evaluates them, it then launches into the process of selecting based on fitness, and finally pops out at the end with an improved solution.
The functions that are currently written in GCscript could be written in C# to simplify the replication of this task, and possibly improve speed.
The algorithm is still in a very trivial use stage, and it needs to be attatched to some no trivial problems to see test it's efficacy.
Other selection algorithms should be explored
A method of avoiding visible graph updates would massively improve speed (by at least an order of magnitude)
Allowing the whole thing to be encapsulated as a single feature would be the ultimate goal, but the constraints of the update cycle are too great currently as far as I know. I'd dearly love to be proved wrong.
This work was initialy undertaken as a part of my masters program in Architecture: Computing and Design at UEL with Paul Coates and Christian Derix. It was sponsered by Aedas Architects, and there wasinvaluable technical advice from Robert Aish and Stelios Dritsas.
The reason behind the project was to attempt to evolve solutions using ecotect to evaluate the fitness. It's a very general project with no specific solution in mind during development. Ben Doherty