Name | Modified | Size | Downloads / Week |
---|---|---|---|
v4.3.0 | 2018-10-28 | ||
v4.2.1 | 2018-09-28 | ||
v4.2.0 | 2018-05-31 | ||
v4.1.0 | 2018-02-14 | ||
v4.0.0 | 2017-11-16 | ||
README.md | 2017-11-16 | 19.4 kB | |
Totals: 6 Items | 19.4 kB | 4 |
Jenetics
Jenetics is an Genetic Algorithm, Evolutionary Algorithm and Genetic Programming library, respectively, written in Java. It is designed with a clear separation of the several concepts of the algorithm, e.g. Gene
, Chromosome
, Genotype
, Phenotype
, Population
and fitness Function
. Jenetics allows you to minimize and maximize the given fitness function without tweaking it. In contrast to other GA implementations, the library uses the concept of an evolution stream (EvolutionStream
) for executing the evolution steps. Since the EvolutionStream
implements the Java Stream interface, it works smoothly with the rest of the Java Stream API.
Other languages
- Jenetics.Net: Experimental .NET Core port in C# of the base library.
Documentation
The library is fully documented (javadoc) and comes with an user manual (pdf).
Requirements
Runtime
- JRE 8: Java runtime version 8 is needed for using the library, respectively for running the examples.
Build time
- JDK 8: The Java JDK 8 must be installed.
- Gradle 4.x: Gradle is used for building the library. (Gradle is download automatically, if you are using the Gradle Wrapper script
./gradlew
, located in the base directory, for building the library.)
Test compile/execution
- TestNG 6.11: Jenetics uses TestNG framework for unit tests.
- Apache Commons Math 3.6: Library is used for testing statistical collectors.
Build Jenetics
For building the Jenetics library from source, download the most recent, stable package version from Github (or Sourceforge) and extract it to some build directory.
$ unzip jenetics-<version>.zip -d <builddir>
<version>
denotes the actual Jenetics version and <builddir>
the actual build directory. Alternatively you can check out the master branch from Github.
$ git clone https://github.com/jenetics/jenetics.git <builddir>
Jenetics uses Gradle as build system and organizes the source into sub-projects (modules). Each sub-project is located in it’s own sub-directory:
Published projects
The following projects/modules are also published to Maven.
- jenetics: This project contains the source code and tests for the Jenetics core-module.
- jenetics.ext: This module contains additional non-standard GA operations and data types.
- jenetics.prog: The modules contains classes which allows to do genetic programming (GP). It seamlessly works with the existing
EvolutionStream
and evolutionEngine
. - jenetics.xml: XML marshalling module for the Jenetics base data structures.
Non-published projects
- jenetics.example: This project contains example code for the core-module.
- jenetics.doc: Contains the code of the web-site and the manual.
- jenetics.tool: This module contains classes used for doing integration testing and algorithmic performance testing. It is also used for creating GA performance measures and creating diagrams from the performance measures.
For building the library change into the <builddir>
directory (or one of the module directory) and call one of the available tasks:
- compileJava: Compiles the Jenetics sources and copies the class files to the
<builddir>/<module-dir>/build/classes/main
directory. - jar: Compiles the sources and creates the JAR files. The artifacts are copied to the
<builddir>/<module-dir>/build/libs
directory. - javadoc: Generates the API documentation. The Javadoc is stored in the
<builddir>/<module-dir>/build/docs
directory - test: Compiles and executes the unit tests. The test results are printed onto the console and a test-report, created by TestNG, is written to
<builddir>/<module-dir>
directory. - clean: Deletes the
<builddir>/build/*
directories and removes all generated artifacts.
For building the library jar from the source call
$ cd <build-dir>
$ ./gradlew jar
Example
Hello World (Ones counting)
The minimum evolution Engine setup needs a genotype factory, Factory<Genotype<?>>
, and a fitness Function
. The Genotype
implements the Factory
interface and can therefore be used as prototype for creating the initial Population
and for creating new random Genotypes
.
import io.jenetics.BitChromosome;
import io.jenetics.BitGene;
import io.jenetics.Genotype;
import io.jenetics.engine.Engine;
import io.jenetics.engine.EvolutionResult;
import io.jenetics.util.Factory;
public class HelloWorld {
// 2.) Definition of the fitness function.
private static Integer eval(Genotype<BitGene> gt) {
return gt.getChromosome()
.as(BitChromosome.class)
.bitCount();
}
public static void main(String[] args) {
// 1.) Define the genotype (factory) suitable
// for the problem.
Factory<Genotype<BitGene>> gtf =
Genotype.of(BitChromosome.of(10, 0.5));
// 3.) Create the execution environment.
Engine<BitGene, Integer> engine = Engine
.builder(HelloWorld::eval, gtf)
.build();
// 4.) Start the execution (evolution) and
// collect the result.
Genotype<BitGene> result = engine.stream()
.limit(100)
.collect(EvolutionResult.toBestGenotype());
System.out.println("Hello World:\n" + result);
}
}
In contrast to other GA implementations, the library uses the concept of an evolution stream (EvolutionStream
) for executing the evolution steps. Since the EvolutionStream
implements the Java Stream interface, it works smoothly with the rest of the Java streaming API. Now let's have a closer look at listing above and discuss this simple program step by step:
-
The probably most challenging part, when setting up a new evolution
Engine
, is to transform the problem domain into a appropriateGenotype
(factory) representation. In our example we want to count the number of ones of aBitChromosome
. Since we are counting only the ones of one chromosome, we are adding only oneBitChromosome
to ourGenotype
. In general, theGenotype
can be created with 1 to n chromosomes. -
Once this is done, the fitness function which should be maximized, can be defined. Utilizing the new language features introduced in Java 8, we simply write a private static method, which takes the genotype we defined and calculate it's fitness value. If we want to use the optimized bit-counting method,
bitCount()
, we have to cast theChromosome<BitGene>
class to the actual usedBitChromosome
class. Since we know for sure that we created the Genotype with aBitChromosome
, this can be done safely. A reference to the eval method is then used as fitness function and passed to theEngine.build
method. -
In the third step we are creating the evolution
Engine
, which is responsible for changing, respectively evolving, a given population. TheEngine
is highly configurable and takes parameters for controlling the evolutionary and the computational environment. For changing the evolutionary behavior, you can set different alterers and selectors. By changing the usedExecutor
service, you control the number of threads, the Engine is allowed to use. An newEngine
instance can only be created via its builder, which is created by calling theEngine.builder
method. -
In the last step, we can create a new
EvolutionStream
from ourEngine
. TheEvolutionStream
is the model or view of the evolutionary process. It serves as a »process handle« and also allows you, among other things, to control the termination of the evolution. In our example, we simply truncate the stream after 100 generations. If you don't limit the stream, theEvolutionStream
will not terminate and run forever. Since theEvolutionStream
extends thejava.util.stream.Stream
interface, it integrates smoothly with the rest of the Java Stream API. The final result, the bestGenotype
in our example, is then collected with one of the predefined collectors of theEvolutionResult
class.
Evolving images
This example tries to approximate a given image by semitransparent polygons. It comes with an Swing UI, where you can immediately start your own experiments. After compiling the sources with
$ ./gradlew compileTestJava
you can start the example by calling
$ ./jrun io.jenetics.example.image.EvolvingImages
The previous image shows the GUI after evolving the default image for about 4,000 generations. With the »Open« button it is possible to load other images for polygonization. The »Save« button allows to store polygonized images in PNG format to disk. At the button of the UI, you can change some of the GA parameters of the example.
Projects using Jenetics
- Chronetic: Chronetic is an open-source time pattern analysis library built to describe time-series data.
- APP4MC: Eclipse APP4MC is a platform for engineering embedded multi- and many-core software systems.
Citations
- Michael Trotter, Guyue Liu, Timothy Wood. Into the Storm: Descrying Optimal Configurations Using Genetic Algorithms and Bayesian Optimization. 2017 IEEE 2nd International Workshops on Foundations and Applications of Self Systems (FASW). Sep. 2017.
- Cuadra P., Krawczyk L., Höttger R., Heisig P., Wolff C. Automated Scheduling for Tightly-Coupled Embedded Multi-core Systems Using Hybrid Genetic Algorithms. Information and Software Technologies: 23rd International Conference, ICIST 2017, Druskininkai, Lithuania. Communications in Computer and Information Science, vol 756. Springer, Cham, Sep. 2017
- Abraão G. Nazário, Fábio R. A. Silva, Raimundo Teive, Leonardo Villa, Antônio Flávio, João Zico, Eire Fragoso, Ederson F. Souza. Automação Domótica Simulada Utilizando Algoritmo Genético Especializado na Redução do Consumo de Energia. Computer on the Beach 2017 pp. 180-189, March 2017.
- Bandaru, S. and Deb, K. Metaheuristic Techniques. Decision Sciences. CRC Press, pp. 693-750, Nov. 2016.
- Lyazid Toumi, Abdelouahab Moussaoui, and Ahmet Ugur. EMeD-Part: An Efficient Methodology for Horizontal Partitioning in Data Warehouses. Proceedings of the International Conference on Intelligent Information Processing, Security and Advanced Communication. Djallel Eddine Boubiche, Faouzi Hidoussi, and Homero Toral Cruz (Eds.). ACM, New York, NY, USA, Article 43, 7 pages, 2015.
- Andreas Holzinger (Editor), Igo Jurisica (Editor). Interactive Knowledge Discovery and Data Mining in Biomedical Informatics. Lecture Notes in Computer Science, Vol. 8401. Springer, 2014.
- Lyazid Toumi, Abdelouahab Moussaoui, Ahmet Ugur. Particle swarm optimization for bitmap join indexes selection problem in data warehouses. The Journal of Supercomputing, Volume 68, Issue 2, pp 672-708, May 2014.
- TANG Yi (Guangzhou Power Supply Bureau Limited, Guangzhou 511400, China) Study on Object-Oriented Reactive Compensation Allocation Optimization Algorithm for Distribution Networks, Oct. 2012.
- John M. Linebarger, Richard J. Detry, Robert J. Glass, Walter E. Beyeler, Arlo L. Ames, Patrick D. Finley, S. Louise Maffitt. Complex Adaptive Systems of Systems Engineering Environment Version 1.0. SAND REPORT, Feb. 2012.
Blogs
- Introduction to Jenetics Library, by baeldung, April 11. 2017
- How to Solve Tough Problems Using Genetic Algorithms, by Tzofia Shiftan, April 6. 2017
- Genetic algorithms with Java, by William Antônio, January 10. 2017
- Jenetics 설치 및 예제, by JDM, May 8. 2015
- 유전 알고리즘 (Genetic Algorithms), by JDM, April 2. 2015
License
The library is licensed under the Apache License, Version 2.0.
Copyright 2007-2017 Franz Wilhelmstötter
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
http://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.
Release notes
4.0.0
Improvements
- #28: Immutable population class. The original
Population
class has been replaced bySeq<Phenotype<G, C>>
. This points to a more functional implementation of the library. - #119:
Chromosome
implementations are now fully immutable. This is an internal change only. - #121:
Mutator
class is easier now to extend. It has been extended with additionalmutate
methods which serves as extension points for onwMutator
implementations. - #123:
Chromosome
with variable number of genes: Most chromosomes can now be created with a variable number of genes.DoubleChromosome.of(0.0, 1.0, IntRange.of(5, 16))
. - #172:
io.jenetics.prngine
library replaces the existing PRNG implementations in theio.jenetics.base
module. - #175: Align random int range generation with
io.jenetics.prngine
library. This is an internal change only. - #180: Change library namespace from
org.jenetics
toio.jenetics
. This is the most invasive change of this release. Users have to adopt the imports in all their code. - #183: Change copyright email address to ...@gmail.com
- #200: Implementation of gene convergence termination: A termination method that stops the evolution when a user-specified percentage of the genes that make up a
Genotype
are deemed as converged. A gene is deemed as converged when the average value of that gene across all of the genotypes in the current population is less than a user-specified percentage away from the maximum gene value across the genotypes. - #253: Removal of deprecated code and classes: mainly
JAXB
marshalling and theLCG64ShiftRandom
class. - #260: Clean room implementation of internal
subset
function. This method was a port from the C++ source written by John Burkardt. The original source has been published under the LGPL licence, which is not compatible to tha Apache 2 licence. To avoid legal issues, the affected method has been reimplemented using the Clean Room method, based on the original book, Combinatorial Algorithms for Computers and Calculators, by Albert Nijenhuis and Herbert Wilf. Theio.jenetics.internal.math.comb.subset
method is now fully compatible with the Apache 2 licence. - #262: Filter for duplicate individuals: It is now possible to intercept the stream of
EvolutionResult
s of the evolutionEngine
:
final Engine<DoubleGene, Integer> engine = Engine.builder(problem)
.mapping(EvolutionResult.toUniquePopulation())
.build();
- #264: Upgrade Gradle to version 4.3.
- #266: The
Seq
serialization should be more robust in the case of implementation changes. - #268: Implementation of an
EliteSelector
. - #269: Cleanup of internal, mathematical helper functions.
- #272: Obey Java naming convention. Two helper classes have been renamed to obey the Java naming conventions.
codecs
->Codecs
andlimits
->Limits
. - #279: Additional
MSeq.swap
method.
Bugs
- #247: Fix the classpath of the
jrun
helper script. - #256: Buggy type signature of
AnyChromosome.of
method.