A genetic algorithm library in Java with focus on easy usage and high performance. Genetic algorithms are meta heuristics inspired by the process of natural selection that belongs to the larger class of evolutionary algorithms. Genetic algorithms can solve optimization problems when there's only an evaluation function available (also known as fitness function).
The following illustration shows the library guessing a sequence of 30 int values with a genetic population size of 3000 hypothesis. At the beginning many components of the population are wrong (=red). With almost every generation (=line) the population improves in fitness and more and more components turn from wrong (=red) to correct (=green).
See sample code.
The process of using the library is summarized in the following picture:
An overview of the classes is given in the following class diagram:
There is a
documentation online for a more detailed discussion on the classes.
There is a stand-alone Java application in the Maven subproject geneticalgorithm-example-int-guessing. This example tries to guess one sequence of integer numbers. One example is to guess the sequence [0, 1, 2, 3, 4].
Please see the example code in GuessingExample.java.
The recommended way of including the library into your project is using Apache Maven:
<dependency>
<groupId>de.sfuhrm</groupId>
<artifactId>geneticalgorithm</artifactId>
<version>3.0.0</version>
</dependency>
The library uses Java 8 functions and will only work with Java 8 and above. There are no libraries needed besides those build-in the JDK.
The algorithm is based on the book Machine learning. Tom M. Mitchell. Published by McGraw-Hill (ISBN 0-07-115467-1).
Copyright 2016-2022 Stephan Fuhrmann
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.