Genetic programming in c++, library suggestions? [closed]
Asked Answered
O

5

8

I'm looking to add some genetic algorithms to an Operations research project I have been involved in. Currently we have a program that aids in optimizing some scheduling and we want to add in some heuristics in the form of genetic algorithms. Are there any good libraries for generic genetic programming/algorithms in c++? Or would you recommend I just code my own?

I should add that while I am not new to c++ I am fairly new to doing this sort of mathematical optimization work in c++ as the group I worked with previously had tended to use a proprietary optimization package.

We have a fitness function that is fairly computationally intensive to evaluate and we have a cluster to run this on so parallelized code is highly desirable.

So is c++ a good language for this? If not please recommend some other ones as I am willing to learn another language if it makes life easier.

thanks!

Outfall answered 18/5, 2010 at 13:11 Comment(1)
A possible duplicate: #687904Achieve
A
4

I would recommend rolling your own. 90% of the work in a GP is coding the genotype, how it gets operated on, and the fitness calculation. These are parts that change for every different problem/project. The actual evolutionary algorithm part is usually quite simple.

There are several GP libraries out there ( http://en.wikipedia.org/wiki/Symbolic_Regression#Implementations ). I would use these as examples and references though.

C++ is a good choice for GP because they tend to be very computationally intensive. Usually, the fitness function is the bottleneck, so it's worthwhile to at least make this part compiled/optimized.

Acute answered 18/5, 2010 at 15:12 Comment(1)
That's a terrible answer. You will end up having nightmares about the MPI communication protocol you will have to implement when this is built-in in GAUL.Emma
T
1

I use GAUL

it's a C library with all you want.
( pthread/fork/openmp/mpi )
( various crossover / mutation function )
( non GA optimisation: Hill-Climbing, N-M Simplex, Simulated annealling, Tabu, ... )

Why build your own library when there is such powerful tools ???

Tinner answered 26/9, 2010 at 21:58 Comment(0)
E
1

I haven't used this personally yet, but the Age Layered Population Structure (ALPS) method has been used to generate human competitive results and has been shown to outperform several popular methods in finding optimal solutions in rough fitness landscapes. Additionally, the link contains source code in C++ FTW.

Epagoge answered 11/10, 2010 at 12:52 Comment(0)
C
0

I have had similar problems. I used to have a complicated problem and defining a solution in terms of a fixed length vector was not desirable. Even a variable length vector does not look attractive. Most of the libraries focus on cases where the cost function is cheap to calculate which did not match my problem. Lack of parallelism is their another pitfall. Expecting the user to allocate memory for being used by the library is adding insult into injury. My cases were even more complicated because most of the libraries check the nonlinear conditions before evaluation. While, I needed to check the nonlinear condition during or after the evaluation based on the result of the evaluation. It is also undesirable when I needed to evaluate the solution to calculate its cost and then I had to recalculate the solution to present it. In most of the cases, I had to write the cost function two times. Once for GA and once for presentation.

Having all of these problems, I eventually, designed my own openGA library which is now mature.

  • This library is based on C++ and distributed with free Mozilla Public License 2.0. It guarantees that using this library does not limit your project and it can be used for commercial or none commercial purposes for free without asking for any permission. Not all libraries are transparent in this sense.
  • It supports three modes of single objective, multiple objective (NSGA-III) and Interactive Genetic Algorithm (IGA).
  • The solution is not mandated to be a vector. It can be any structure with any customized design containing any optional values with variable length. This feature makes this library suitable for Genetic Programming (GP) applications.
  • C++11 is used. Template feature allows flexibility of the solution structure design.
  • The standard library is enough to use this library. There is no dependency beyond that. The entire library is also a single header file for ease of use.
  • The library supports parallelism by default unless you turn it off. If you have an N-core CPU, the number of threads are set to N by default. You can change the settings. You can also set if the solution evaluations are distributed between threads equally or they are assigned to any thread which has finished its job and is currently idle.
  • The solution evaluation is separated from calculation of the final cost. It means that your evaluation function can simulate the system and keep a lot of information. Your cost function is called later and reports the cost based on the evaluation. While your evaluation results are kept to be used later by the user. You do not need to re-calculate it again.
  • You can reject a solution at any time during the evaluation. No waste of time. In fact, the evaluation and constraint check are integrated.
  • The GA assist feature help you to produce the C++ code base from the information you provide.

If these features match what you need, I recommend having a look at the user manual and the examples of openGA.

The number of the readers and citation of the related publication as well as its github favorite marks is increasing and its usage is keep growing.

Cagey answered 16/10, 2019 at 8:26 Comment(0)
E
-2

I suggest you have a look into the matlab optimization toolkit - it comes with GAs out of the box, you only haver to code the fitness function (and a function to generate inital population eventually) and I believe matlab has some C++ interoperability so you could code you functions in C++. I am using it for my experiments and a very nice feature is that you get all sorts of charts out of the box as well.

Said so - if your aim is to learn about genetic algorithms you're better off coding it, but if you just want to run experiments matlab and C++ (or even just matlab) is a good option.

Ejective answered 22/5, 2010 at 9:2 Comment(2)
It's not so much that the Matlab licence costs that much but rather the restrictions I have on packaging the code. Were there no restrictions on the Matlab licence I'd certainly do that.Outfall
if this is a commercial endeavor and you're not just running experiments I can see how that would be a drawbackEjective

© 2022 - 2024 — McMap. All rights reserved.