Genetic programming in C #

I was looking for examples of good genetic programming for C #. Does anyone know of good online resources? I wonder if there is a C # library there for evolutionary / genetic programming?

+56
c # genetic-algorithm evolutionary-algorithm genetic-programming
Aug 17 '08 at 23:25
source share
13 answers

After developing my own didactic application for genetic programming, I found a complete genetic programming system called AForge.NET Genetics . This is part of the Aforge.NET library. It is licensed under LGPL.

+27
Jun 23 '09 at 0:22
source share

Last year, MSDN published an article on genetic programming: Genetic Algorithms: Survival of the fittest using forms of Windows

+23
Aug 17 '08 at 23:28
source share

I would recommend against creating assemblies if you absolutely do not need it, especially if you are just starting out with a genetic algorithm.

The genetic algorithm is easiest to implement when the target language is functional and dynamically typed. That is why most studies of the genetic algorithm are written in LISP. As a result, if you are going to implement it in C #, you are probably better off defining your own mini-tree language, having a tree generation algorithm and just interpreting the trees when the time comes to start each iteration of the algorithm,

I did such a project when I was in college (implementing the genetic algorithm in C #), and that was the approach I took.

Performing this method will give you the advantage of only having 1 view for working with (AST view), which is optimally suited for both executing and “propagating” the genetic algorithm.

Alternatively, if you try to generate assemblies, you will probably end up adding a lot of unnecessary complexity to the application. Currently, the CLR does not allow you to unload the assembly from the application domain if the entire application domain is not destroyed. This would mean that you would need to deploy a separate application domain for each generated program at each iteration of the algorithm to avoid introducing a giant memory leak into your application. In general, all this will simply add a bunch of unnecessary annoyance.

Interpreted ASTs, on the other hand, collect garbage like any other object, and therefore you do not need to become desecrated with multiple application domains. If for performance reasons you want to get gen-code, you can add the final result later. However, I would recommend that you do this using the DynamicMethod class. This will allow you to convert the AST to a compiled delegate dynamically at runtime. This will allow you to deploy a single DLL, while keeping the code generation material as simple as possible. In addition, DynamicMethod instances are garbage collectors, so you can use them as part of a genetic algorithm to speed things up there.

+13
Aug 26 '08 at 6:14
source share

You might be able to implement genetic programming using LINQ expression trees - it will generate something more useful than random IL generation.

+10
Aug 18 '08 at 1:00
source share

I saw a good high-level discussion of this channel on the Mike Swanson channel at http://channel9.msdn.com/posts/Charles/Algorithms-and-Data-Structures-Mike-Swanson-Genetic-Session-Scheduler/

+6
Aug 17 '08 at 23:28
source share

Do you mean actual genetic programming, unlike genetic algorithms in general?

If so, C # /. NET is not the best language for it. LISP, for example, has always been the backbone of the GP.

However, if you need to, you probably want to dynamically generate CIL / MSIL. You can do this with System.Reflection.Emit , however I would recommend Mono.Cecil . It lacks good documents (as if they were reflected by their radiation). But it offers much better emission and reflection of the assembly.

Another problem is that it is less than trivial to download code and then delete it in the .net framework. At least you cannot unload assemblies. You can offload application areas, but the whole business of downloading code into a separate appdomain and calling it from the outside can become quite dirty. The .NET 3.5 System.Addin tools should make this easier.

+4
Aug 18 '08 at 0:54
source share

If you are interested in genetic algorithms or heuristic optimization in general, you can take a look at HeuristicLab . It has been developed for several years, 1.5 years after we released the new version. It is programmed in C # 4 and has a nice graphical interface. There are many algorithms that are already available, for example, genetic algorithm, genetic programming, evolution strategy, local search, taboo search, optimization of particle pianos, simulated annealing and much more. There are also several problems associated with the problem of vehicle routing, a travel seller, optimization of real functions, a satchel, a problem of quadratic assignment, classification, regression, and many others. There are also tutorials, and we have built-in protocol buffers so that you can communicate with external programs to evaluate decisions. Licensed under the GPL. In 2009, the software received the Microsoft Award from Microsoft Austria.

We also wrote a book on this topic: Genetic Algorithms and Genetic Programming .

+4
Oct 17 '11 at 17:56
source share

I'm reading the Genetic Programming Field Guide right now (free PDF download). It is also available in paperback. It discusses the use of a library written in Java called TinyGP . From this you can get mileage. I did not start making any real programs, but I hope to apply some of the concepts in C #.

+3
Sep 25 '08 at 3:04
source share

I was looking for ECJ for C # .NET 4.0 if you are interested in a full-featured evolutionary computing infrastructure. The package includes everything from the original ECJ Java project, including all working samples.

I also wrote 500 unit tests to test many aspects of the conversion. But many more tests are required. In particular, aspects of distributed computing have not been fully tested. This is because I plan to convert from ECJ simple use of sockets into a more robust strategy using WCF and WF. I will also redesign the structure to use TPL (parallel task library).

In any case, you can download the initial conversion here:

http://branecloud.codeplex.com

I am also in the process of converting several other frameworks from Java to .NET that relate to research on “synthetic intelligence” (when I can find the time).

Ben

+3
Jun 01 2018-11-11T00:
source share

You can try GeneticSharp .

It has all of the classic GA operations, such as selection, crossover, mutation, reinstallation, and termination.

It is very extensible, you can define your own chromosomes, fitness function, population formation strategy, and all the above operations.

It can be used in many applications, such as C # libraries and Unity 3D games, there are samples that run it in the GTK # application . and playing Unity 3D games .

It also works in Win and OSX.

Here is a basic example of using the library:

var selection = new EliteSelection(); var crossover = new OrderedCrossover(); var mutation = new ReverseSequenceMutation(); var fitness = new YourFitnessFunction(); var chromosome = new YourChromosome(); var population = new Population (50, 70, chromosome); var ga = new GeneticAlgorithm(population, fitness, selection, crossover, mutation); ga.Start(); 
+3
Jul 10 '14 at 10:23
source share

I have a free product that can help. The .Net 4.0 Genetic Algorithm is a single .Net 4.0 assembly with some supporting articles.

+3
Oct 11 '14 at 16:40
source share

Manning's book: " Metaprogramming in .NET " devotes a large section of the GP to expression trees.

+2
May 21 '14 at 18:50
source share

I support ECJ port in C #. It's great.

+1
Oct 22 '08 at 0:48
source share



All Articles