You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2022/01/31 23:47:50 UTC

[commons-math] branch feature__MATH-1563__genetic_algorithm updated (7e2213f -> 07deb60)

This is an automated email from the ASF dual-hosted git repository.

erans pushed a change to branch feature__MATH-1563__genetic_algorithm
in repository https://gitbox.apache.org/repos/asf/commons-math.git.


    from 7e2213f  Merge branch 'feature__MATH-1563__genetic_algorithm' of https://gitbox.apache.org/repos/asf/commons-math into feature__MATH-1563__genetic_algorithm
     new 765242f  MATH-1563: Miscellaneous updates.
     new 07deb60  Consolidate POM files.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../examples-ga-math-functions-adaptive}/LICENCE   |   0
 .../examples-ga-math-functions-adaptive}/NOTICE    |   0
 .../examples-ga-math-functions-adaptive}/pom.xml   |  28 ++---
 .../adaptive/AdaptiveMathFunctionOptimizer.java    |  96 +++++++++++++++
 .../adaptive/ConvergenceGraphPlotter.java}         |  10 +-
 .../ga/mathfunctions/adaptive/Coordinate.java}     |   6 +-
 .../mathfunctions/adaptive/CoordinateDecoder.java} |  16 +--
 .../ga/mathfunctions/adaptive/MathFunction.java}   |   8 +-
 .../ga/mathfunctions/adaptive/StandAlone.java      | 135 +++++++++++++++++++++
 .../ga/mathfunctions/adaptive}/package-info.java   |   2 +-
 .../examples-ga-math-functions-legacy}/LICENCE     |   0
 .../examples-ga-math-functions-legacy}/NOTICE      |   0
 .../examples-ga-math-functions-legacy}/pom.xml     |  37 +++---
 .../legacy/LegacyBinaryChromosome.java             |  12 +-
 .../legacy/LegacyMathFunctionOptimizer.java}       |  72 +++++------
 .../ga/mathfunctions/legacy/StandAlone.java        | 101 +++++++++++++++
 .../legacy/UnchangedBestFitness.java               |   2 +-
 .../ga/mathfunctions/legacy}/package-info.java     |   2 +-
 .../examples-ga/examples-ga-math-functions/pom.xml |  81 ++++++-------
 ...phPlotter.java => ConvergenceGraphPlotter.java} |  10 +-
 .../DimensionNCoordinate.java => Coordinate.java}  |   6 +-
 ...mension2Decoder.java => CoordinateDecoder.java} |  33 ++---
 ...sion2FitnessFunction.java => MathFunction.java} |  16 +--
 .../ga/mathfunctions/MathFunctionOptimizer.java    | 101 +++++++++++++++
 .../examples/ga/mathfunctions/StandAlone.java      | 110 +++++++++++++++++
 .../Dimension2FunctionAdaptiveOptimizer.java       | 114 -----------------
 .../dimension2/Dimension2FunctionOptimizer.java    | 114 -----------------
 .../dimension2/legacy/package-info.java            |  20 ---
 .../ga/mathfunctions/dimension2/package-info.java  |  20 ---
 .../DimensionNFunctionAdaptiveOptimizer.java       | 114 -----------------
 .../dimensionN/DimensionNFunctionOptimizer.java    | 113 -----------------
 .../ga/mathfunctions/dimensionN/package-info.java  |  20 ---
 .../examples/ga/mathfunctions}/package-info.java   |   2 +-
 .../examples/ga/mathfunctions/utils/Constants.java |  55 ---------
 .../examples-ga/examples-ga-tsp-legacy}/LICENCE    |   0
 .../examples-ga/examples-ga-tsp-legacy}/NOTICE     |   0
 .../examples-ga-tsp-legacy}/pom.xml                |  34 +++---
 .../math4/examples/ga/tsp/legacy}/City.java        |   2 +-
 .../examples/ga/tsp/legacy}/DistanceMatrix.java    |  18 +--
 .../ga/tsp/legacy/LegacyTSPOptimizer.java}         |  61 +++++-----
 .../math4/examples/ga/tsp/legacy/StandAlone.java   | 103 ++++++++++++++++
 .../examples/ga/tsp/legacy/TSPChromosome.java      |   9 +-
 .../ga/tsp/legacy/UnchangedBestFitness.java        |   0
 .../math4/examples/ga/tsp/legacy/package-info.java |   0
 .../examples-ga/examples-ga-tsp/pom.xml            |  86 ++++++-------
 .../commons/math4/examples/ga/tsp/City.java}       |  41 ++++---
 ...phPlotter.java => ConvergenceGraphPlotter.java} |   8 +-
 .../ga/tsp/{commons => }/DistanceMatrix.java       |  18 +--
 .../commons/math4/examples/ga/tsp/StandAlone.java  | 111 +++++++++++++++++
 .../math4/examples/ga/tsp/TSPFitnessFunction.java  |  11 +-
 .../math4/examples/ga/tsp/TSPOptimizer.java        |  79 +++++-------
 .../math4/examples/ga/tsp/utils/Constants.java     |  65 ----------
 commons-math-examples/examples-ga/pom.xml          |  88 ++++++++------
 .../resources/spotbugs/spotbugs-exclude-filter.xml |   0
 .../resources/spotbugs/spotbugs-exclude-filter.xml |   0
 commons-math-examples/pom.xml                      |  22 ++++
 commons-math-ga/pom.xml                            | 116 ++++++++++--------
 .../commons/math4/ga/AdaptiveGeneticAlgorithm.java |   2 +-
 .../apache/commons/math4/ga/GeneticAlgorithm.java  |   2 +-
 .../math4/ga/chromosome/BinaryChromosome.java      |  10 +-
 .../AbstractListChromosomeCrossoverPolicy.java     |   2 +-
 .../commons/math4/ga/crossover/CycleCrossover.java |   2 +-
 .../math4/ga/crossover/OrderedCrossover.java       |   1 -
 .../math4/ga/crossover/UniformCrossover.java       |   1 -
 .../ga/decoder/AbstractListChromosomeDecoder.java  |   3 +-
 .../AbstractListChromosomeMutationPolicy.java      |  18 ++-
 .../commons/math4/ga/mutation/BinaryMutation.java  |  14 +--
 .../math4/ga/mutation/IntegralValuedMutation.java  |  29 ++++-
 .../math4/ga/mutation/RealValuedMutation.java      |  19 ++-
 .../math4/ga/population/ListPopulation.java        |  11 +-
 .../math4/ga/chromosome/BinaryChromosomeTest.java  |   9 ++
 .../math4/ga/dummy/DummyListChromosomeDecoder.java |   6 -
 .../AbstractListChromosomeMutationPolicyTest.java  |  44 -------
 .../math4/ga/mutation/BinaryMutationTest.java      |   4 +-
 .../ga/mutation/IntegralValuedMutationTest.java    |   5 +-
 .../math4/ga/mutation/RealValuedMutationTest.java  |  31 ++++-
 pom.xml                                            |   1 -
 .../checkstyle/checkstyle-suppressions.xml         |   1 +
 78 files changed, 1341 insertions(+), 1202 deletions(-)
 copy {commons-math-neuralnet => commons-math-examples/examples-ga/examples-ga-math-functions-adaptive}/LICENCE (100%)
 copy {commons-math-neuralnet => commons-math-examples/examples-ga/examples-ga-math-functions-adaptive}/NOTICE (100%)
 copy commons-math-examples/{examples-sofm/tsp => examples-ga/examples-ga-math-functions-adaptive}/pom.xml (58%)
 create mode 100644 commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/AdaptiveMathFunctionOptimizer.java
 rename commons-math-examples/examples-ga/{examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimNGraphPlotter.java => examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/ConvergenceGraphPlotter.java} (91%)
 copy commons-math-examples/examples-ga/{examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNCoordinate.java => examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/Coordinate.java} (89%)
 rename commons-math-examples/examples-ga/{examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNDecoder.java => examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/CoordinateDecoder.java} (76%)
 rename commons-math-examples/examples-ga/{examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNFitnessFunction.java => examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/MathFunction.java} (83%)
 create mode 100644 commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/StandAlone.java
 rename commons-math-examples/examples-ga/{examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons => examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive}/package-info.java (92%)
 copy {commons-math-neuralnet => commons-math-examples/examples-ga/examples-ga-math-functions-legacy}/LICENCE (100%)
 copy {commons-math-neuralnet => commons-math-examples/examples-ga/examples-ga-math-functions-legacy}/NOTICE (100%)
 copy commons-math-examples/{examples-sofm/tsp => examples-ga/examples-ga-math-functions-legacy}/pom.xml (58%)
 rename commons-math-examples/examples-ga/{examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2 => examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions}/legacy/LegacyBinaryChromosome.java (81%)
 rename commons-math-examples/examples-ga/{examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/Dimension2FunctionOptimizerLegacy.java => examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/LegacyMathFunctionOptimizer.java} (56%)
 create mode 100644 commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/StandAlone.java
 rename commons-math-examples/examples-ga/{examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2 => examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions}/legacy/UnchangedBestFitness.java (96%)
 rename commons-math-examples/examples-ga/{examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/utils => examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy}/package-info.java (92%)
 rename commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/{dimension2/Dim2GraphPlotter.java => ConvergenceGraphPlotter.java} (91%)
 rename commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/{dimensionN/DimensionNCoordinate.java => Coordinate.java} (89%)
 rename commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/{dimension2/Dimension2Decoder.java => CoordinateDecoder.java} (56%)
 rename commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/{dimension2/Dimension2FitnessFunction.java => MathFunction.java} (68%)
 create mode 100644 commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/MathFunctionOptimizer.java
 create mode 100644 commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/StandAlone.java
 delete mode 100644 commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2FunctionAdaptiveOptimizer.java
 delete mode 100644 commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2FunctionOptimizer.java
 delete mode 100644 commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/package-info.java
 delete mode 100644 commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/package-info.java
 delete mode 100644 commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNFunctionAdaptiveOptimizer.java
 delete mode 100644 commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNFunctionOptimizer.java
 delete mode 100644 commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/package-info.java
 rename commons-math-examples/examples-ga/{examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/utils => examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions}/package-info.java (93%)
 delete mode 100644 commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/utils/Constants.java
 copy {commons-math-neuralnet => commons-math-examples/examples-ga/examples-ga-tsp-legacy}/LICENCE (100%)
 copy {commons-math-neuralnet => commons-math-examples/examples-ga/examples-ga-tsp-legacy}/NOTICE (100%)
 copy commons-math-examples/{examples-sofm/chinese-rings => examples-ga/examples-ga-tsp-legacy}/pom.xml (58%)
 rename commons-math-examples/examples-ga/{examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons => examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy}/City.java (96%)
 copy commons-math-examples/examples-ga/{examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons => examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy}/DistanceMatrix.java (82%)
 rename commons-math-examples/examples-ga/{examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/TSPOptimizerLegacy.java => examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/LegacyTSPOptimizer.java} (62%)
 create mode 100644 commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/StandAlone.java
 rename commons-math-examples/examples-ga/{examples-ga-tsp => examples-ga-tsp-legacy}/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/TSPChromosome.java (84%)
 rename commons-math-examples/examples-ga/{examples-ga-tsp => examples-ga-tsp-legacy}/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/UnchangedBestFitness.java (100%)
 rename commons-math-examples/examples-ga/{examples-ga-tsp => examples-ga-tsp-legacy}/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/package-info.java (100%)
 rename commons-math-examples/examples-ga/{examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2Coordinate.java => examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/City.java} (60%)
 rename commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/{utils/GraphPlotter.java => ConvergenceGraphPlotter.java} (94%)
 rename commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/{commons => }/DistanceMatrix.java (83%)
 create mode 100644 commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/StandAlone.java
 delete mode 100644 commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/utils/Constants.java
 copy {src => commons-math-examples/examples-ga/src}/main/resources/spotbugs/spotbugs-exclude-filter.xml (100%)
 copy {src => commons-math-examples/examples-sofm/src}/main/resources/spotbugs/spotbugs-exclude-filter.xml (100%)
 delete mode 100644 commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/AbstractListChromosomeMutationPolicyTest.java

[commons-math] 02/02: Consolidate POM files.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch feature__MATH-1563__genetic_algorithm
in repository https://gitbox.apache.org/repos/asf/commons-math.git

commit 07deb60ecf11782d18c06deb098339109fe6bd5e
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Tue Feb 1 00:47:00 2022 +0100

    Consolidate POM files.
---
 .../examples-ga-math-functions-adaptive/pom.xml    |  65 ++++--------
 .../examples-ga-math-functions-legacy/pom.xml      |  69 ++++++------
 .../examples-ga/examples-ga-math-functions/pom.xml |  65 ++++--------
 .../examples-ga/examples-ga-tsp-legacy/pom.xml     |  78 +++++++-------
 .../examples-ga/examples-ga-tsp/pom.xml            |  70 ++++---------
 commons-math-examples/examples-ga/pom.xml          |  81 ++++++++------
 commons-math-examples/pom.xml                      |  22 ++++
 commons-math-ga/pom.xml                            | 116 +++++++++++----------
 8 files changed, 279 insertions(+), 287 deletions(-)

diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/pom.xml b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/pom.xml
index 1b53bea..b73679d 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/pom.xml
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/pom.xml
@@ -16,48 +16,29 @@
    limitations under the License.
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.commons</groupId>
-        <artifactId>examples-ga</artifactId>
-        <version>4.0-SNAPSHOT</version>
-    </parent>
-    <artifactId>examples-ga-math-functions-adaptive</artifactId>
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.commons</groupId>
+    <artifactId>examples-ga</artifactId>
+    <version>4.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>examples-ga-math-functions-adaptive</artifactId>
+  <version>4.0-SNAPSHOT</version>
+  <name>GA: Math Functions Adaptive</name>
 
-    <properties>
-        <maven.compiler.source>1.8</maven.compiler.source>
-        <maven.compiler.target>1.8</maven.compiler.target>
+  <properties>
+    <!-- OSGi -->
+    <commons.osgi.symbolicName>org.apache.commons.math4.examples.ga.mathfunctions.adaptive</commons.osgi.symbolicName>
+    <commons.osgi.export>org.apache.commons.math4.examples.ga.mathfunctions.adaptive</commons.osgi.export>
+    <!-- Java 9+ -->
+    <commons.automatic.module.name>org.apache.commons.math4.examples.ga.mathfunctions.adaptive</commons.automatic.module.name>
+    <!-- Workaround to avoid duplicating config files. -->
+    <math.parent.dir>${basedir}/../../..</math.parent.dir>
 
-        <!-- OSGi -->
-        <commons.osgi.symbolicName>org.apache.commons.math4.examples.ga.mathfunctions.adaptive</commons.osgi.symbolicName>
-        <commons.osgi.export>org.apache.commons.math4.examples.ga.mathfunctions.adaptive</commons.osgi.export>
-        <!-- Java 9+ -->
-        <commons.automatic.module.name>org.apache.commons.math4.examples.ga.mathfunctions.adaptive</commons.automatic.module.name>
-        <!-- Workaround to avoid duplicating config files. -->
-        <math.parent.dir>${basedir}/../../..</math.parent.dir>
+    <uberjar.name>examples-ga-mathfunctions-adaptive</uberjar.name>
+    <project.mainClass>org.apache.commons.math4.examples.ga.mathfunctions.adaptive.StandAlone</project.mainClass>
+  </properties>
 
-        <uberjar.name>examples-ga-mathfunctions-adaptive</uberjar.name>
-        <project.mainClass>org.apache.commons.math4.examples.ga.mathfunctions.adaptive.StandAlone</project.mainClass>
-        <slf4jVersion>1.7.32</slf4jVersion>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math-ga</artifactId>
-            <version>4.0-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.jfree</groupId>
-            <artifactId>jfreechart</artifactId>
-            <version>1.5.3</version>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <version>${slf4jVersion}</version>
-        </dependency>
-    </dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/pom.xml b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/pom.xml
index 874fc82..d4bda0b 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/pom.xml
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/pom.xml
@@ -16,37 +16,38 @@
    limitations under the License.
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.commons</groupId>
-        <artifactId>examples-ga</artifactId>
-        <version>4.0-SNAPSHOT</version>
-    </parent>
-    <artifactId>examples-ga-math-functions-legacy</artifactId>
-
-    <properties>
-        <maven.compiler.source>1.8</maven.compiler.source>
-        <maven.compiler.target>1.8</maven.compiler.target>
-
-        <!-- OSGi -->
-        <commons.osgi.symbolicName>org.apache.commons.math4.examples.ga.mathfunctions.legacy</commons.osgi.symbolicName>
-        <commons.osgi.export>org.apache.commons.math4.examples.ga.mathfunctions.legacy</commons.osgi.export>
-        <!-- Java 9+ -->
-        <commons.automatic.module.name>org.apache.commons.math4.examples.ga.mathfunctions.legacy</commons.automatic.module.name>
-        <!-- Workaround to avoid duplicating config files. -->
-        <math.parent.dir>${basedir}/../../..</math.parent.dir>
-
-        <uberjar.name>examples-ga-mathfunctions-legacy</uberjar.name>
-        <project.mainClass>org.apache.commons.math4.examples.ga.mathfunctions.legacy.StandAlone</project.mainClass>
-        <slf4jVersion>1.7.32</slf4jVersion>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math3</artifactId>
-        </dependency>
-    </dependencies>
-</project>
\ No newline at end of file
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.commons</groupId>
+    <artifactId>examples-ga</artifactId>
+    <version>4.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>examples-ga-math-functions-legacy</artifactId>
+  <version>4.0-SNAPSHOT</version>
+  <name>GA: Math Functions (legacy)</name>
+
+  <properties>
+    <!-- OSGi -->
+    <commons.osgi.symbolicName>org.apache.commons.math4.examples.ga.mathfunctions.legacy</commons.osgi.symbolicName>
+    <commons.osgi.export>org.apache.commons.math4.examples.ga.mathfunctions.legacy</commons.osgi.export>
+    <!-- Java 9+ -->
+    <commons.automatic.module.name>org.apache.commons.math4.examples.ga.mathfunctions.legacy</commons.automatic.module.name>
+    <!-- Workaround to avoid duplicating config files. -->
+    <math.parent.dir>${basedir}/../../..</math.parent.dir>
+
+    <uberjar.name>examples-ga-mathfunctions-legacy</uberjar.name>
+    <project.mainClass>org.apache.commons.math4.examples.ga.mathfunctions.legacy.StandAlone</project.mainClass>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-math3</artifactId>
+    </dependency>
+
+  </dependencies>
+
+</project>
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/pom.xml b/commons-math-examples/examples-ga/examples-ga-math-functions/pom.xml
index aa2f8af..de5a314 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/pom.xml
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions/pom.xml
@@ -16,48 +16,29 @@
    limitations under the License.
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.commons</groupId>
-        <artifactId>examples-ga</artifactId>
-        <version>4.0-SNAPSHOT</version>
-    </parent>
-    <artifactId>examples-ga-math-functions</artifactId>
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.commons</groupId>
+    <artifactId>examples-ga</artifactId>
+    <version>4.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>examples-ga-math-functions</artifactId>
+  <version>4.0-SNAPSHOT</version>
+  <name>GA: Math Functions</name>
 
-    <properties>
-        <maven.compiler.source>1.8</maven.compiler.source>
-        <maven.compiler.target>1.8</maven.compiler.target>
+  <properties>
+    <!-- OSGi -->
+    <commons.osgi.symbolicName>org.apache.commons.math4.examples.ga.mathfunctions</commons.osgi.symbolicName>
+    <commons.osgi.export>org.apache.commons.math4.examples.ga.mathfunctions</commons.osgi.export>
+    <!-- Java 9+ -->
+    <commons.automatic.module.name>org.apache.commons.math4.examples.ga.mathfunctions</commons.automatic.module.name>
+    <!-- Workaround to avoid duplicating config files. -->
+    <math.parent.dir>${basedir}/../../..</math.parent.dir>
 
-        <!-- OSGi -->
-        <commons.osgi.symbolicName>org.apache.commons.math4.examples.ga.mathfunctions</commons.osgi.symbolicName>
-        <commons.osgi.export>org.apache.commons.math4.examples.ga.mathfunctions</commons.osgi.export>
-        <!-- Java 9+ -->
-        <commons.automatic.module.name>org.apache.commons.math4.examples.ga.mathfunctions</commons.automatic.module.name>
-        <!-- Workaround to avoid duplicating config files. -->
-        <math.parent.dir>${basedir}/../../..</math.parent.dir>
+    <uberjar.name>examples-ga-mathfunctions</uberjar.name>
+    <project.mainClass>org.apache.commons.math4.examples.ga.mathfunctions.StandAlone</project.mainClass>
+  </properties>
 
-        <uberjar.name>examples-ga-mathfunctions</uberjar.name>
-        <project.mainClass>org.apache.commons.math4.examples.ga.mathfunctions.StandAlone</project.mainClass>
-        <slf4jVersion>1.7.32</slf4jVersion>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math-ga</artifactId>
-            <version>4.0-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.jfree</groupId>
-            <artifactId>jfreechart</artifactId>
-            <version>1.5.3</version>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <version>${slf4jVersion}</version>
-        </dependency>
-    </dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp-legacy/pom.xml b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/pom.xml
index 65f8dbc..21eda05 100644
--- a/commons-math-examples/examples-ga/examples-ga-tsp-legacy/pom.xml
+++ b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/pom.xml
@@ -16,41 +16,43 @@
    limitations under the License.
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.commons</groupId>
-        <artifactId>examples-ga</artifactId>
-        <version>4.0-SNAPSHOT</version>
-    </parent>
-    <artifactId>examples-ga-tsp-legacy</artifactId>
-    <properties>
-        <maven.compiler.source>1.8</maven.compiler.source>
-        <maven.compiler.target>1.8</maven.compiler.target>
-
-        <!-- OSGi -->
-        <commons.osgi.symbolicName>org.apache.commons.math4.examples.ga.tsp.legacy</commons.osgi.symbolicName>
-        <commons.osgi.export>org.apache.commons.math4.examples.ga.tsp.legacy</commons.osgi.export>
-        <!-- Java 9+ -->
-        <commons.automatic.module.name>org.apache.commons.math4.examples.ga.tsp.legacy</commons.automatic.module.name>
-        <!-- Workaround to avoid duplicating config files. -->
-        <math.parent.dir>${basedir}/../../..</math.parent.dir>
-
-        <uberjar.name>examples-ga-tsp-legacy</uberjar.name>
-        <project.mainClass>org.apache.commons.math4.examples.ga.tsp.legacy.StandAlone</project.mainClass>
-        <slf4jVersion>1.7.32</slf4jVersion>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math3</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-csv</artifactId>
-            <version>1.9.0</version>
-        </dependency>
-    </dependencies>
-</project>
\ No newline at end of file
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.commons</groupId>
+    <artifactId>examples-ga</artifactId>
+    <version>4.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>examples-ga-tsp-legacy</artifactId>
+  <version>4.0-SNAPSHOT</version>
+  <name>GA: TSP (legacy)</name>
+
+  <properties>
+    <!-- OSGi -->
+    <commons.osgi.symbolicName>org.apache.commons.math4.examples.ga.tsp.legacy</commons.osgi.symbolicName>
+    <commons.osgi.export>org.apache.commons.math4.examples.ga.tsp.legacy</commons.osgi.export>
+    <!-- Java 9+ -->
+    <commons.automatic.module.name>org.apache.commons.math4.examples.ga.tsp.legacy</commons.automatic.module.name>
+    <!-- Workaround to avoid duplicating config files. -->
+    <math.parent.dir>${basedir}/../../..</math.parent.dir>
+
+    <uberjar.name>examples-ga-tsp-legacy</uberjar.name>
+    <project.mainClass>org.apache.commons.math4.examples.ga.tsp.legacy.StandAlone</project.mainClass>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-math3</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-csv</artifactId>
+    </dependency>
+    
+  </dependencies>
+
+</project>
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/pom.xml b/commons-math-examples/examples-ga/examples-ga-tsp/pom.xml
index f42dd22..c63e39d 100644
--- a/commons-math-examples/examples-ga/examples-ga-tsp/pom.xml
+++ b/commons-math-examples/examples-ga/examples-ga-tsp/pom.xml
@@ -16,53 +16,29 @@
    limitations under the License.
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.commons</groupId>
-        <artifactId>examples-ga</artifactId>
-        <version>4.0-SNAPSHOT</version>
-    </parent>
-    <artifactId>examples-ga-tsp</artifactId>
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.commons</groupId>
+    <artifactId>examples-ga</artifactId>
+    <version>4.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>examples-ga-tsp</artifactId>
+  <version>4.0-SNAPSHOT</version>
+  <name>GA: TSP</name>
 
-    <properties>
-        <maven.compiler.source>1.8</maven.compiler.source>
-        <maven.compiler.target>1.8</maven.compiler.target>
+  <properties>
+    <!-- OSGi -->
+    <commons.osgi.symbolicName>org.apache.commons.math4.examples.ga.tsp</commons.osgi.symbolicName>
+    <commons.osgi.export>org.apache.commons.math4.examples.ga.tsp</commons.osgi.export>
+    <!-- Java 9+ -->
+    <commons.automatic.module.name>org.apache.commons.math4.examples.ga.tsp</commons.automatic.module.name>
+    <!-- Workaround to avoid duplicating config files. -->
+    <math.parent.dir>${basedir}/../../..</math.parent.dir>
 
-        <!-- OSGi -->
-        <commons.osgi.symbolicName>org.apache.commons.math4.examples.ga.tsp</commons.osgi.symbolicName>
-        <commons.osgi.export>org.apache.commons.math4.examples.ga.tsp</commons.osgi.export>
-        <!-- Java 9+ -->
-        <commons.automatic.module.name>org.apache.commons.math4.examples.ga.tsp</commons.automatic.module.name>
-        <!-- Workaround to avoid duplicating config files. -->
-        <math.parent.dir>${basedir}/../../..</math.parent.dir>
+    <uberjar.name>examples-ga-tsp</uberjar.name>
+    <project.mainClass>org.apache.commons.math4.examples.ga.tsp.StandAlone</project.mainClass>
+  </properties>
 
-        <uberjar.name>examples-ga-tsp</uberjar.name>
-        <project.mainClass>org.apache.commons.math4.examples.ga.tsp.StandAlone</project.mainClass>
-        <slf4jVersion>1.7.32</slf4jVersion>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math-ga</artifactId>
-            <version>4.0-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.jfree</groupId>
-            <artifactId>jfreechart</artifactId>
-            <version>1.5.3</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-csv</artifactId>
-            <version>1.9.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <version>${slf4jVersion}</version>
-        </dependency>
-    </dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/commons-math-examples/examples-ga/pom.xml b/commons-math-examples/examples-ga/pom.xml
index dc91479..4c9e189 100644
--- a/commons-math-examples/examples-ga/pom.xml
+++ b/commons-math-examples/examples-ga/pom.xml
@@ -16,34 +16,53 @@
    limitations under the License.
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.commons</groupId>
-        <artifactId>commons-math-examples</artifactId>
-        <version>4.0-SNAPSHOT</version>
-    </parent>
-    <artifactId>examples-ga</artifactId>
-    <packaging>pom</packaging>
-    <name>examples-genetic-algorithm</name>
-
-    <properties>
-        <!-- Workaround to avoid duplicating config files. -->
-        <math.parent.dir>${basedir}/../..</math.parent.dir>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>info.picocli</groupId>
-            <artifactId>picocli</artifactId>
-        </dependency>
-    </dependencies>
-    <modules>
-        <module>examples-ga-math-functions</module>
-        <module>examples-ga-math-functions-adaptive</module>
-        <module>examples-ga-math-functions-legacy</module>
-        <module>examples-ga-tsp</module>
-        <module>examples-ga-tsp-legacy</module>
-    </modules>
-</project>
\ No newline at end of file
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.commons</groupId>
+    <artifactId>commons-math-examples</artifactId>
+    <version>4.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>examples-ga</artifactId>
+  <packaging>pom</packaging>
+  <name>GA</name>
+
+  <properties>
+    <!-- Workaround to avoid duplicating config files. -->
+    <math.parent.dir>${basedir}/../..</math.parent.dir>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-math4-ga</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>info.picocli</groupId>
+      <artifactId>picocli</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jfree</groupId>
+      <artifactId>jfreechart</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+    </dependency>
+
+  </dependencies>
+
+  <modules>
+    <module>examples-ga-math-functions</module>
+    <module>examples-ga-math-functions-adaptive</module>
+    <module>examples-ga-math-functions-legacy</module>
+    <module>examples-ga-tsp</module>
+    <module>examples-ga-tsp-legacy</module>
+  </modules>
+
+</project>
diff --git a/commons-math-examples/pom.xml b/commons-math-examples/pom.xml
index 96be12a..d6eabf2 100644
--- a/commons-math-examples/pom.xml
+++ b/commons-math-examples/pom.xml
@@ -52,6 +52,9 @@
     <math.rng.version>1.4</math.rng.version>
     <math.geometry.version>1.0</math.geometry.version>
     <math.imaging.version>1.0-alpha3-SNAPSHOT</math.imaging.version>
+    <math.slf4j.version>1.7.32</math.slf4j.version>
+    <math.jfreechart.version>1.5.3</math.jfreechart.version>
+    <math.csv.version>1.9.0</math.csv.version>
 
     <!-- Disable JApiCmp failures (but keep the report). The examples API is allowed to change. -->
     <commons.japicmp.breakBuildOnBinaryIncompatibleModifications>false</commons.japicmp.breakBuildOnBinaryIncompatibleModifications>
@@ -110,7 +113,26 @@
         <version>${math.picocli.version}</version>
       </dependency>
 
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-simple</artifactId>
+        <version>${math.slf4j.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jfree</groupId>
+        <artifactId>jfreechart</artifactId>
+        <version>${math.jfreechart.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-csv</artifactId>
+        <version>${math.csv.version}</version>
+      </dependency>
+
     </dependencies>
+
   </dependencyManagement>
 
   <build>
diff --git a/commons-math-ga/pom.xml b/commons-math-ga/pom.xml
index a2a3689..eddae3c 100644
--- a/commons-math-ga/pom.xml
+++ b/commons-math-ga/pom.xml
@@ -1,54 +1,64 @@
-<?xml version="1.0"?>
-<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
-    license agreements. See the NOTICE file distributed with this work for additional 
-    information regarding copyright ownership. The ASF licenses this file to 
-    You 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. -->
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.commons</groupId>
-        <artifactId>commons-math-parent</artifactId>
-        <version>4.0-SNAPSHOT</version>
-    </parent>
-    <artifactId>commons-math-ga</artifactId>
-    <name>genetic algorithm</name>
-
-    <description />
-
-    <properties>
-        <!-- The Java Module System Name -->
-        <commons.module.name>org.apache.commons.math4.ga</commons.module.name>
-        <!-- This value must reflect the current name of the base package. -->
-        <commons.osgi.symbolicName>org.apache.commons.math4.ga</commons.osgi.symbolicName>
-        <!-- OSGi -->
-        <commons.osgi.export>org.apache.commons.math4.ga</commons.osgi.export>
-        <!-- Workaround to avoid duplicating config files. -->
-        <math.parent.dir>${basedir}/..</math.parent.dir>
-        <slf4jVersion>1.7.32</slf4jVersion>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-numbers-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-rng-simple</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <version>${slf4jVersion}</version>
-        </dependency>
-    </dependencies>
-
-</project>
\ No newline at end of file
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.commons</groupId>
+    <artifactId>commons-math-parent</artifactId>
+    <version>4.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>commons-math4-ga</artifactId>
+  <name>Genetic Algorithms</name>
+
+  <description>Genetic Algorithms</description>
+
+  <properties>
+    <!-- The Java Module System Name -->
+    <commons.module.name>org.apache.commons.math4.ga</commons.module.name>
+    <!-- This value must reflect the current name of the base package. -->
+    <commons.osgi.symbolicName>org.apache.commons.math4.ga</commons.osgi.symbolicName>
+    <!-- OSGi -->
+    <commons.osgi.export>org.apache.commons.math4.ga</commons.osgi.export>
+    <!-- Workaround to avoid duplicating config files. -->
+    <math.parent.dir>${basedir}/..</math.parent.dir>
+    <math.slf4j.version>1.7.32</math.slf4j.version>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-numbers-core</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-rng-simple</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>${math.slf4j.version}</version>
+    </dependency>
+
+  </dependencies>
+
+</project>

[commons-math] 01/02: MATH-1563: Miscellaneous updates.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch feature__MATH-1563__genetic_algorithm
in repository https://gitbox.apache.org/repos/asf/commons-math.git

commit 765242fb8965506b599dd60837b2bd85037ae597
Author: avbasak1 <av...@in.ibm.com>
AuthorDate: Sun Jan 2 18:54:37 2022 +0530

    MATH-1563: Miscellaneous updates.
---
 .../examples-ga-math-functions-adaptive/LICENCE    | 201 +++++++++++++++++++++
 .../examples-ga-math-functions-adaptive/NOTICE     |   5 +
 .../pom.xml                                        |  33 ++--
 .../adaptive/AdaptiveMathFunctionOptimizer.java    |  96 ++++++++++
 .../adaptive/ConvergenceGraphPlotter.java}         |  10 +-
 .../ga/mathfunctions/adaptive/Coordinate.java}     |   6 +-
 .../mathfunctions/adaptive/CoordinateDecoder.java} |  16 +-
 .../ga/mathfunctions/adaptive/MathFunction.java}   |   8 +-
 .../ga/mathfunctions/adaptive/StandAlone.java      | 135 ++++++++++++++
 .../ga/mathfunctions/adaptive}/package-info.java   |   2 +-
 .../examples-ga-math-functions-legacy/LICENCE      | 201 +++++++++++++++++++++
 .../examples-ga-math-functions-legacy/NOTICE       |   5 +
 .../pom.xml                                        |  34 ++--
 .../legacy/LegacyBinaryChromosome.java             |  12 +-
 .../legacy/LegacyMathFunctionOptimizer.java}       |  72 ++++----
 .../ga/mathfunctions/legacy/StandAlone.java        | 101 +++++++++++
 .../legacy/UnchangedBestFitness.java               |   2 +-
 .../ga/mathfunctions/legacy}/package-info.java     |   2 +-
 .../examples-ga/examples-ga-math-functions/pom.xml |  38 ++--
 ...phPlotter.java => ConvergenceGraphPlotter.java} |  10 +-
 .../DimensionNCoordinate.java => Coordinate.java}  |   6 +-
 ...mension2Decoder.java => CoordinateDecoder.java} |  33 ++--
 ...sion2FitnessFunction.java => MathFunction.java} |  16 +-
 .../ga/mathfunctions/MathFunctionOptimizer.java    | 101 +++++++++++
 .../examples/ga/mathfunctions/StandAlone.java      | 110 +++++++++++
 .../Dimension2FunctionAdaptiveOptimizer.java       | 114 ------------
 .../dimension2/Dimension2FunctionOptimizer.java    | 114 ------------
 .../dimension2/legacy/package-info.java            |  20 --
 .../ga/mathfunctions/dimension2/package-info.java  |  20 --
 .../DimensionNFunctionAdaptiveOptimizer.java       | 114 ------------
 .../dimensionN/DimensionNFunctionOptimizer.java    | 113 ------------
 .../ga/mathfunctions/dimensionN/package-info.java  |  20 --
 .../examples/ga/mathfunctions}/package-info.java   |   2 +-
 .../examples/ga/mathfunctions/utils/Constants.java |  55 ------
 .../examples-ga/examples-ga-tsp-legacy/LICENCE     | 201 +++++++++++++++++++++
 .../examples-ga/examples-ga-tsp-legacy/NOTICE      |   5 +
 .../{ => examples-ga-tsp-legacy}/pom.xml           |  36 ++--
 .../math4/examples/ga/tsp/legacy}/City.java        |   2 +-
 .../examples/ga/tsp/legacy}/DistanceMatrix.java    |  18 +-
 .../ga/tsp/legacy/LegacyTSPOptimizer.java}         |  61 +++----
 .../math4/examples/ga/tsp/legacy/StandAlone.java   | 103 +++++++++++
 .../examples/ga/tsp/legacy/TSPChromosome.java      |   9 +-
 .../ga/tsp/legacy/UnchangedBestFitness.java        |   0
 .../math4/examples/ga/tsp/legacy/package-info.java |   0
 .../examples-ga/examples-ga-tsp/pom.xml            |  40 ++--
 .../commons/math4/examples/ga/tsp/City.java}       |  41 +++--
 ...phPlotter.java => ConvergenceGraphPlotter.java} |   8 +-
 .../ga/tsp/{commons => }/DistanceMatrix.java       |  18 +-
 .../commons/math4/examples/ga/tsp/StandAlone.java  | 111 ++++++++++++
 .../math4/examples/ga/tsp/TSPFitnessFunction.java  |  11 +-
 .../math4/examples/ga/tsp/TSPOptimizer.java        |  79 ++++----
 .../math4/examples/ga/tsp/utils/Constants.java     |  65 -------
 commons-math-examples/examples-ga/pom.xml          |  17 +-
 .../resources/spotbugs/spotbugs-exclude-filter.xml |  66 +++++++
 .../resources/spotbugs/spotbugs-exclude-filter.xml |  66 +++++++
 .../commons/math4/ga/AdaptiveGeneticAlgorithm.java |   2 +-
 .../apache/commons/math4/ga/GeneticAlgorithm.java  |   2 +-
 .../math4/ga/chromosome/BinaryChromosome.java      |  10 +-
 .../AbstractListChromosomeCrossoverPolicy.java     |   2 +-
 .../commons/math4/ga/crossover/CycleCrossover.java |   2 +-
 .../math4/ga/crossover/OrderedCrossover.java       |   1 -
 .../math4/ga/crossover/UniformCrossover.java       |   1 -
 .../ga/decoder/AbstractListChromosomeDecoder.java  |   3 +-
 .../AbstractListChromosomeMutationPolicy.java      |  18 +-
 .../commons/math4/ga/mutation/BinaryMutation.java  |  14 +-
 .../math4/ga/mutation/IntegralValuedMutation.java  |  29 ++-
 .../math4/ga/mutation/RealValuedMutation.java      |  19 +-
 .../math4/ga/population/ListPopulation.java        |  11 +-
 .../math4/ga/chromosome/BinaryChromosomeTest.java  |   9 +
 .../math4/ga/dummy/DummyListChromosomeDecoder.java |   6 -
 .../AbstractListChromosomeMutationPolicyTest.java  |  44 -----
 .../math4/ga/mutation/BinaryMutationTest.java      |   4 +-
 .../ga/mutation/IntegralValuedMutationTest.java    |   5 +-
 .../math4/ga/mutation/RealValuedMutationTest.java  |  31 +++-
 pom.xml                                            |   1 -
 .../checkstyle/checkstyle-suppressions.xml         |   1 +
 76 files changed, 1946 insertions(+), 1053 deletions(-)

diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/LICENCE b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/LICENCE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/LICENCE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/NOTICE b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/NOTICE
new file mode 100644
index 0000000..28031e8
--- /dev/null
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/NOTICE
@@ -0,0 +1,5 @@
+Apache Commons Math
+Copyright 2001-2022 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/commons-math-examples/examples-ga/pom.xml b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/pom.xml
similarity index 61%
copy from commons-math-examples/examples-ga/pom.xml
copy to commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/pom.xml
index 8432483..1b53bea 100644
--- a/commons-math-examples/examples-ga/pom.xml
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/pom.xml
@@ -21,16 +21,26 @@
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.commons</groupId>
-        <artifactId>commons-math-examples</artifactId>
+        <artifactId>examples-ga</artifactId>
         <version>4.0-SNAPSHOT</version>
     </parent>
-    <artifactId>examples-ga</artifactId>
-    <packaging>pom</packaging>
-    <name>examples-genetic-algorithm</name>
+    <artifactId>examples-ga-math-functions-adaptive</artifactId>
 
     <properties>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+
+        <!-- OSGi -->
+        <commons.osgi.symbolicName>org.apache.commons.math4.examples.ga.mathfunctions.adaptive</commons.osgi.symbolicName>
+        <commons.osgi.export>org.apache.commons.math4.examples.ga.mathfunctions.adaptive</commons.osgi.export>
+        <!-- Java 9+ -->
+        <commons.automatic.module.name>org.apache.commons.math4.examples.ga.mathfunctions.adaptive</commons.automatic.module.name>
         <!-- Workaround to avoid duplicating config files. -->
-        <math.parent.dir>${basedir}/../..</math.parent.dir>
+        <math.parent.dir>${basedir}/../../..</math.parent.dir>
+
+        <uberjar.name>examples-ga-mathfunctions-adaptive</uberjar.name>
+        <project.mainClass>org.apache.commons.math4.examples.ga.mathfunctions.adaptive.StandAlone</project.mainClass>
+        <slf4jVersion>1.7.32</slf4jVersion>
     </properties>
 
     <dependencies>
@@ -40,17 +50,14 @@
             <version>4.0-SNAPSHOT</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math3</artifactId>
-        </dependency>
-        <dependency>
             <groupId>org.jfree</groupId>
             <artifactId>jfreechart</artifactId>
             <version>1.5.3</version>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <version>${slf4jVersion}</version>
+        </dependency>
     </dependencies>
-    <modules>
-        <module>examples-ga-math-functions</module>
-        <module>examples-ga-tsp</module>
-    </modules>
 </project>
\ No newline at end of file
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/AdaptiveMathFunctionOptimizer.java b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/AdaptiveMathFunctionOptimizer.java
new file mode 100644
index 0000000..8a1c303
--- /dev/null
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/AdaptiveMathFunctionOptimizer.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+package org.apache.commons.math4.examples.ga.mathfunctions.adaptive;
+
+import org.apache.commons.math4.ga.AbstractGeneticAlgorithm;
+import org.apache.commons.math4.ga.AdaptiveGeneticAlgorithm;
+import org.apache.commons.math4.ga.chromosome.BinaryChromosome;
+import org.apache.commons.math4.ga.chromosome.Chromosome;
+import org.apache.commons.math4.ga.convergence.StoppingCondition;
+import org.apache.commons.math4.ga.convergence.UnchangedBestFitness;
+import org.apache.commons.math4.ga.crossover.OnePointBinaryCrossover;
+import org.apache.commons.math4.ga.crossover.rategenerator.AdaptiveLinearMaximumRankBasedCrossoverRateGenerator;
+import org.apache.commons.math4.ga.mutation.BinaryMutation;
+import org.apache.commons.math4.ga.mutation.rategenerator.AdaptiveLinearMutationRateGenerator;
+import org.apache.commons.math4.ga.population.ListPopulation;
+import org.apache.commons.math4.ga.population.Population;
+import org.apache.commons.math4.ga.selection.TournamentSelection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class represents an optimizer for a 2-dimensional math function using
+ * genetic algorithm.
+ */
+public final class AdaptiveMathFunctionOptimizer {
+
+    /** length of chromosome. **/
+    private static final int CHROMOSOME_LENGTH_PER_DIMENSION = 12;
+
+    /** encoding for console logger. **/
+    private static final String ENCODING = "UTF-8";
+
+    /** instance of logger. **/
+    private final Logger logger = LoggerFactory.getLogger(AdaptiveMathFunctionOptimizer.class);
+
+    public void optimize(int dimension,
+            double minCrossoverRate,
+            double maxCrossoverRate,
+            double minMutationRate,
+            double maxMutationRate,
+            double elitismRate,
+            int tournamentSize,
+            int generationCountWithUnchangedBestFitness,
+            int populationSize) {
+
+        // initialize a new genetic algorithm
+        final AbstractGeneticAlgorithm<Coordinate> ga = new AdaptiveGeneticAlgorithm<Coordinate>(
+                new OnePointBinaryCrossover<Coordinate>(),
+                new AdaptiveLinearMaximumRankBasedCrossoverRateGenerator<>(minCrossoverRate, maxCrossoverRate),
+                new BinaryMutation<>(), new AdaptiveLinearMutationRateGenerator<>(minMutationRate, maxMutationRate),
+                new TournamentSelection<>(tournamentSize), elitismRate);
+
+        // stopping condition
+        final StoppingCondition<Coordinate> stopCond = new UnchangedBestFitness<>(
+                generationCountWithUnchangedBestFitness);
+
+        // run the algorithm
+        final Population<Coordinate> finalPopulation = ga.evolve(getInitialPopulation(dimension, populationSize),
+                stopCond);
+
+        // best chromosome from the final population
+        final Chromosome<Coordinate> bestFinal = finalPopulation.getFittestChromosome();
+
+        logger.info("*********************************************");
+        logger.info("***********Optimization Result***************");
+        logger.info(bestFinal.toString());
+
+    }
+
+    private static Population<Coordinate> getInitialPopulation(int dimension, int populationSize) {
+        final Population<Coordinate> population = new ListPopulation<>(populationSize);
+        final MathFunction fitnessFunction = new MathFunction();
+        final CoordinateDecoder decoder = new CoordinateDecoder();
+        for (int i = 0; i < populationSize; i++) {
+            population.addChromosome(BinaryChromosome.<Coordinate>randomChromosome(
+                    dimension * CHROMOSOME_LENGTH_PER_DIMENSION, fitnessFunction, decoder));
+        }
+        return population;
+    }
+
+}
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dim2GraphPlotter.java b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/ConvergenceGraphPlotter.java
similarity index 91%
rename from commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dim2GraphPlotter.java
rename to commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/ConvergenceGraphPlotter.java
index eca37e8..fff8a80 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dim2GraphPlotter.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/ConvergenceGraphPlotter.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math4.examples.ga.mathfunctions.dimension2;
+package org.apache.commons.math4.examples.ga.mathfunctions.adaptive;
 
 import java.awt.BorderLayout;
 import java.util.List;
@@ -39,7 +39,7 @@ import org.jfree.data.xy.XYSeriesCollection;
 /**
  * This class represents the graph plotter during optimization.
  */
-public class Dim2GraphPlotter extends JFrame implements ConvergenceListener<Dimension2Coordinate> {
+public class ConvergenceGraphPlotter extends JFrame implements ConvergenceListener<Coordinate> {
 
     /**
      * Generated serialversionId.
@@ -55,7 +55,7 @@ public class Dim2GraphPlotter extends JFrame implements ConvergenceListener<Dime
      * @param xAxisLabel  x axis label
      * @param yAxisLabel  y axis label
      */
-    public Dim2GraphPlotter(String plotSubject, String xAxisLabel, String yAxisLabel) {
+    public ConvergenceGraphPlotter(String plotSubject, String xAxisLabel, String yAxisLabel) {
         super(plotSubject);
 
         final JPanel chartPanel = createChartPanel(plotSubject, xAxisLabel, yAxisLabel);
@@ -135,8 +135,8 @@ public class Dim2GraphPlotter extends JFrame implements ConvergenceListener<Dime
      * {@inheritDoc}
      */
     @Override
-    public void notify(int generation, Population<Dimension2Coordinate> population) {
-        PopulationStatisticalSummary<Dimension2Coordinate> populationStatisticalSummary =
+    public void notify(int generation, Population<Coordinate> population) {
+        PopulationStatisticalSummary<Coordinate> populationStatisticalSummary =
                 new PopulationStatisticalSummaryImpl<>(population);
         this.addDataPoint("Average", generation, populationStatisticalSummary.getMeanFitness());
         this.addDataPoint("Best", generation, populationStatisticalSummary.getMaxFitness());
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNCoordinate.java b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/Coordinate.java
similarity index 89%
copy from commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNCoordinate.java
copy to commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/Coordinate.java
index 98a31bc..51585d7 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNCoordinate.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/Coordinate.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.math4.examples.ga.mathfunctions.dimensionN;
+package org.apache.commons.math4.examples.ga.mathfunctions.adaptive;
 
 import java.util.List;
 
@@ -22,7 +22,7 @@ import java.util.List;
  * This class represents the coordinate of the problem domain i.e. the phenotype
  * of chromosome.
  */
-public class DimensionNCoordinate {
+public class Coordinate {
 
     /** coordinate of all dimensions. **/
     private final List<Double> values;
@@ -31,7 +31,7 @@ public class DimensionNCoordinate {
      * constructor.
      * @param values coordinates of all dimensions.
      */
-    public DimensionNCoordinate(List<Double> values) {
+    public Coordinate(List<Double> values) {
         this.values = values;
     }
 
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNDecoder.java b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/CoordinateDecoder.java
similarity index 76%
rename from commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNDecoder.java
rename to commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/CoordinateDecoder.java
index 9579815..4bbe853 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNDecoder.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/CoordinateDecoder.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.math4.examples.ga.mathfunctions.dimensionN;
+package org.apache.commons.math4.examples.ga.mathfunctions.adaptive;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -25,19 +25,19 @@ import org.apache.commons.math4.ga.decoder.Decoder;
 
 /**
  * Decoder to convert chromosome's binary genotype to phenotype
- * {@link DimensionNCoordinate}.
+ * {@link Coordinate}.
  */
-public class DimensionNDecoder implements Decoder<DimensionNCoordinate> {
+public class CoordinateDecoder implements Decoder<Coordinate> {
 
     /**
      * decode the binary representation of chromosome to
-     * {@link DimensionNCoordinate}.
+     * {@link Coordinate}.
      * @param chromosome The {@link Chromosome}
      */
     @Override
-    public DimensionNCoordinate decode(Chromosome<DimensionNCoordinate> chromosome) {
-        final BinaryChromosome<DimensionNCoordinate> binaryChromosome =
-                (BinaryChromosome<DimensionNCoordinate>) chromosome;
+    public Coordinate decode(Chromosome<Coordinate> chromosome) {
+        final BinaryChromosome<Coordinate> binaryChromosome =
+                (BinaryChromosome<Coordinate>) chromosome;
         final long length = binaryChromosome.getLength();
         final List<Double> coordinates = new ArrayList<>();
 
@@ -46,7 +46,7 @@ public class DimensionNDecoder implements Decoder<DimensionNCoordinate> {
             coordinates.add(Integer.parseUnsignedInt(dimensionStrValue, 2) / 100d);
         }
 
-        return new DimensionNCoordinate(coordinates);
+        return new Coordinate(coordinates);
     }
 
 }
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNFitnessFunction.java b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/MathFunction.java
similarity index 83%
rename from commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNFitnessFunction.java
rename to commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/MathFunction.java
index 1c0d7db..a38cd28 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNFitnessFunction.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/MathFunction.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math4.examples.ga.mathfunctions.dimensionN;
+package org.apache.commons.math4.examples.ga.mathfunctions.adaptive;
 
 import org.apache.commons.math4.ga.fitness.FitnessFunction;
 
@@ -23,15 +23,15 @@ import org.apache.commons.math4.ga.fitness.FitnessFunction;
  * This class represents the mathematical fitness function for optimizing a 2
  * dimension mathematical function.
  */
-public class DimensionNFitnessFunction implements FitnessFunction<DimensionNCoordinate> {
+public class MathFunction implements FitnessFunction<Coordinate> {
 
     /**
      * Computes the fitness value based on the decoded chromosome.
-     * @param coordinate The {@link DimensionNCoordinate}
+     * @param coordinate The {@link Coordinate}
      * @return the fitness value
      */
     @Override
-    public double compute(DimensionNCoordinate coordinate) {
+    public double compute(Coordinate coordinate) {
         double sumOfSquare = 0.0;
         for (Double value : coordinate.getValues()) {
             sumOfSquare += Math.pow(value, 2);
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/StandAlone.java b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/StandAlone.java
new file mode 100644
index 0000000..0b55f20
--- /dev/null
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/StandAlone.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.commons.math4.examples.ga.mathfunctions.adaptive;
+
+import org.apache.commons.math4.ga.internal.exception.GeneticException;
+import org.apache.commons.math4.ga.listener.ConvergenceListenerRegistry;
+import org.apache.commons.math4.ga.listener.PopulationStatisticsLogger;
+
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+@Command(name = "adaptive-mathfunction-optimizer", mixinStandardHelpOptions = true,
+        version = "adaptive-mathfunction-optimizer 1.0")
+public class StandAlone implements Runnable {
+
+    /** number of dimension. **/
+    @Option(names = "-d", paramLabel = "DIMENSION", required = true, description = "Dimension of problem domain.")
+    private int dimension;
+
+    /** size of tournament. **/
+    @Option(names = "-t", paramLabel = "TOURNAMENT_SIZE", required = true, description = "Tournament size.")
+    private int tournamentSize;
+
+    /** size of population. **/
+    @Option(names = "-p", paramLabel = "POPULATION_SIZE", required = true, description = "Size of population.")
+    private int populationSize;
+
+    /** minimum rate of crossover. **/
+    @Option(names = "-c", paramLabel = "MIN_CROSSOVER_RATE",
+            description = "Crossover rate (default: ${DEFAULT-VALUE}).")
+    private double minCrossoverRate = 0;
+
+    /** maximum rate of crossover. **/
+    @Option(names = "-C", paramLabel = "MAX_CROSSOVER_RATE",
+            description = "Crossover rate (default: ${DEFAULT-VALUE}).")
+    private double maxCrossoverRate = 1.0;
+
+    /** minimum rate of mutation. **/
+    @Option(names = "-m", paramLabel = "MIN_MUTATION_RATE",
+            description = "Minimum Mutation rate (default: ${DEFAULT-VALUE}).")
+    private double minMutationRate = 0;
+
+    /** maximum rate of mutation. **/
+    @Option(names = "-M", paramLabel = "MAX_MUTATION_RATE",
+            description = "Maximum Mutation rate (default: ${DEFAULT-VALUE}).")
+    private double maxMutationRate = 0.1;
+
+    /** rate of elitism. **/
+    @Option(names = "-e", paramLabel = "ELITISM_RATE", description = "Elitism rate (default: ${DEFAULT-VALUE}).")
+    private double elitismRate = 0.25;
+
+    /** number of generations with unchanged best fitness. **/
+    @Option(names = "-g", paramLabel = "GENERATIONS_EVOLVED_WITH_UNCHANGED_BEST_FITNESS",
+            description = "No of generations evolved with unchanged best fitness (default: ${DEFAULT-VALUE}).")
+    private int generationsEvolvedWithUnchangedBestFitness = 50;
+
+    public static void main(String[] args) {
+        CommandLine.run(new StandAlone(), args);
+    }
+
+    /**
+     * This method is responsible for validating input and invoking
+     * {@link AdaptiveMathFunctionOptimizer}.
+     */
+    @Override
+    public void run() {
+
+        // validate all input options.
+        validateInput();
+
+        final AdaptiveMathFunctionOptimizer optimizer = new AdaptiveMathFunctionOptimizer();
+
+        final ConvergenceListenerRegistry<Coordinate> convergenceListenerRegistry = ConvergenceListenerRegistry
+                .getInstance();
+        convergenceListenerRegistry.addConvergenceListener(new PopulationStatisticsLogger<Coordinate>());
+        convergenceListenerRegistry
+                .addConvergenceListener(new ConvergenceGraphPlotter("Convergence Stats", "generation", "fitness"));
+
+        optimizer.optimize(dimension, minCrossoverRate, maxCrossoverRate, minMutationRate, maxMutationRate, elitismRate,
+                tournamentSize, generationsEvolvedWithUnchangedBestFitness, populationSize);
+
+    }
+
+    private void validateInput() {
+        if (this.dimension < 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Dimension should be > 0.");
+        }
+        if (this.tournamentSize < 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Tournament size should be > 0.");
+        }
+        if (populationSize < 2) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Population size should be > 1.");
+        }
+        if (minCrossoverRate > 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Minimum crossover rate should be <= 1.");
+        }
+        if (maxCrossoverRate > 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Maximum crossover rate should be <= 1.");
+        }
+        if (maxCrossoverRate < minCrossoverRate) {
+            throw new GeneticException(GeneticException.TOO_LARGE, minCrossoverRate, maxCrossoverRate);
+        }
+        if (minMutationRate > 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Minimum mutation rate should be <= 1.");
+        }
+        if (maxMutationRate > 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Maximum mutation rate should be <= 1.");
+        }
+        if (minMutationRate > maxMutationRate) {
+            throw new GeneticException(GeneticException.TOO_LARGE, minMutationRate, maxMutationRate);
+        }
+        if (elitismRate >= 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Elitism rate should be < 1.");
+        }
+        if (generationsEvolvedWithUnchangedBestFitness < 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT,
+                    "Number of generations evolved with unchanged best fitness should be >= 1.");
+        }
+    }
+}
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/utils/package-info.java b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/package-info.java
similarity index 92%
rename from commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/utils/package-info.java
rename to commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/package-info.java
index 5caadde..0f5050f 100644
--- a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/utils/package-info.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-adaptive/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/adaptive/package-info.java
@@ -17,4 +17,4 @@
 /**
  * This package provides Genetic Algorithms components and implementations.
  */
-package org.apache.commons.math4.examples.ga.tsp.utils;
+package org.apache.commons.math4.examples.ga.mathfunctions.adaptive;
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/LICENCE b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/LICENCE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/LICENCE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/NOTICE b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/NOTICE
new file mode 100644
index 0000000..28031e8
--- /dev/null
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/NOTICE
@@ -0,0 +1,5 @@
+Apache Commons Math
+Copyright 2001-2022 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/commons-math-examples/examples-ga/pom.xml b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/pom.xml
similarity index 61%
copy from commons-math-examples/examples-ga/pom.xml
copy to commons-math-examples/examples-ga/examples-ga-math-functions-legacy/pom.xml
index 8432483..874fc82 100644
--- a/commons-math-examples/examples-ga/pom.xml
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/pom.xml
@@ -21,36 +21,32 @@
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.commons</groupId>
-        <artifactId>commons-math-examples</artifactId>
+        <artifactId>examples-ga</artifactId>
         <version>4.0-SNAPSHOT</version>
     </parent>
-    <artifactId>examples-ga</artifactId>
-    <packaging>pom</packaging>
-    <name>examples-genetic-algorithm</name>
+    <artifactId>examples-ga-math-functions-legacy</artifactId>
 
     <properties>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+
+        <!-- OSGi -->
+        <commons.osgi.symbolicName>org.apache.commons.math4.examples.ga.mathfunctions.legacy</commons.osgi.symbolicName>
+        <commons.osgi.export>org.apache.commons.math4.examples.ga.mathfunctions.legacy</commons.osgi.export>
+        <!-- Java 9+ -->
+        <commons.automatic.module.name>org.apache.commons.math4.examples.ga.mathfunctions.legacy</commons.automatic.module.name>
         <!-- Workaround to avoid duplicating config files. -->
-        <math.parent.dir>${basedir}/../..</math.parent.dir>
+        <math.parent.dir>${basedir}/../../..</math.parent.dir>
+
+        <uberjar.name>examples-ga-mathfunctions-legacy</uberjar.name>
+        <project.mainClass>org.apache.commons.math4.examples.ga.mathfunctions.legacy.StandAlone</project.mainClass>
+        <slf4jVersion>1.7.32</slf4jVersion>
     </properties>
 
     <dependencies>
         <dependency>
             <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math-ga</artifactId>
-            <version>4.0-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
             <artifactId>commons-math3</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.jfree</groupId>
-            <artifactId>jfreechart</artifactId>
-            <version>1.5.3</version>
-        </dependency>
     </dependencies>
-    <modules>
-        <module>examples-ga-math-functions</module>
-        <module>examples-ga-tsp</module>
-    </modules>
 </project>
\ No newline at end of file
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/LegacyBinaryChromosome.java b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/LegacyBinaryChromosome.java
similarity index 81%
rename from commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/LegacyBinaryChromosome.java
rename to commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/LegacyBinaryChromosome.java
index 66c4615..cac3577 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/LegacyBinaryChromosome.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/LegacyBinaryChromosome.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math4.examples.ga.mathfunctions.dimension2.legacy;
+package org.apache.commons.math4.examples.ga.mathfunctions.legacy;
 
 import java.util.List;
 
@@ -46,12 +46,12 @@ public class LegacyBinaryChromosome extends BinaryChromosome {
         for (Integer allele : alleles) {
             allelesStr.append(Integer.toBinaryString(allele));
         }
+        double val = 0.0;
+        for (int i = 0; i < allelesStr.length(); i += 12) {
+            val += Math.pow(Integer.parseInt(allelesStr.substring(i, i + 12), 2) / 100.0, 2);
+        }
 
-        final double x = Integer.parseInt(allelesStr.substring(0, 12), 2) / 100.0;
-        final double y = Integer.parseInt(allelesStr.substring(12, 24), 2) / 100.0;
-
-        return -Math.pow(Math.pow(x, 2) + Math.pow(y, 2), .25) *
-                (Math.pow(Math.sin(50 * Math.pow(Math.pow(x, 2) + Math.pow(y, 2), .1)), 2) + 1);
+        return -Math.pow(val, .25) * (Math.pow(Math.sin(50 * Math.pow(val, .1)), 2) + 1);
     }
 
     /**
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/Dimension2FunctionOptimizerLegacy.java b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/LegacyMathFunctionOptimizer.java
similarity index 56%
rename from commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/Dimension2FunctionOptimizerLegacy.java
rename to commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/LegacyMathFunctionOptimizer.java
index b523d41..ff59919 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/Dimension2FunctionOptimizerLegacy.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/LegacyMathFunctionOptimizer.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.math4.examples.ga.mathfunctions.dimension2.legacy;
+package org.apache.commons.math4.examples.ga.mathfunctions.legacy;
 
 import java.io.BufferedWriter;
 import java.io.IOException;
@@ -29,73 +29,67 @@ import org.apache.commons.math3.genetics.OnePointCrossover;
 import org.apache.commons.math3.genetics.Population;
 import org.apache.commons.math3.genetics.StoppingCondition;
 import org.apache.commons.math3.genetics.TournamentSelection;
-import org.apache.commons.math4.examples.ga.mathfunctions.utils.Constants;
-import org.apache.commons.math4.ga.internal.exception.GeneticException;
 
 /**
  * This class represents an optimizer for a 2-dimensional math function using
  * the legacy genetic algorithm.
  */
-public class Dimension2FunctionOptimizerLegacy {
+public final class LegacyMathFunctionOptimizer {
 
-    /** number of dimension. **/
-    private static final int DIMENSION = 2;
+    /** length of chromosome per dimension. **/
+    private static final int CHROMOSOME_LENGTH_PER_DIMENSION = 12;
 
-    /** size of tournament. **/
-    private static final int TOURNAMENT_SIZE = 3;
-
-    /**
-     * Optimizes the 2-dimensional fitness function.
-     * @param args arguments
-     */
-    public static void main(String[] args) {
-        final Population initPopulation = getInitialPopulation();
-        final Dimension2FunctionOptimizerLegacy simulation = new Dimension2FunctionOptimizerLegacy();
-
-        simulation.optimize(initPopulation);
-    }
+    /** encoding for console logger. **/
+    private static final String ENCODING = "UTF-8";
 
     /**
      * Optimizes the initial population using legacy genetic algorithm.
-     * @param initial initial {@link Population}
+     * @param dimension                               dimension of problem domain
+     * @param crossoverRate                           rate of crossover
+     * @param mutationRate                            rate of mutation
+     * @param elitismRate                             rate of elitism
+     * @param tournamentSize                          size of tournament
+     * @param generationCountWithUnchangedBestFitness no of generation evolved with
+     *                                                unchanged best fitness
+     * @param populationSize                          size of population
      */
-    public void optimize(Population initial) {
+    public void optimize(int dimension,
+            double crossoverRate,
+            double mutationRate,
+            double elitismRate,
+            int tournamentSize,
+            int generationCountWithUnchangedBestFitness,
+            int populationSize) {
 
         // initialize a new genetic algorithm
-        final GeneticAlgorithm geneticAlgorithm = new GeneticAlgorithm(new OnePointCrossover<>(),
-                Constants.CROSSOVER_RATE, new BinaryMutation(), Constants.AVERAGE_MUTATION_RATE,
-                new TournamentSelection(TOURNAMENT_SIZE));
+        final GeneticAlgorithm geneticAlgorithm = new GeneticAlgorithm(new OnePointCrossover<>(), crossoverRate,
+                new BinaryMutation(), mutationRate, new TournamentSelection(tournamentSize));
 
         // stopping condition
-        final StoppingCondition stopCond = new UnchangedBestFitness(
-                Constants.GENERATION_COUNT_WITH_UNCHANGED_BEST_FUTNESS);
+        final StoppingCondition stopCond = new UnchangedBestFitness(generationCountWithUnchangedBestFitness);
 
         // run the algorithm
-        final Population finalPopulation = geneticAlgorithm.evolve(initial, stopCond);
+        final Population finalPopulation = geneticAlgorithm
+                .evolve(getInitialPopulation(dimension, populationSize, elitismRate), stopCond);
 
         // best chromosome from the final population
         final Chromosome bestFinal = finalPopulation.getFittestChromosome();
 
-        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out, Constants.ENCODING))) {
+        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out, ENCODING))) {
             writer.write("*********************************************");
             writer.newLine();
             writer.write("***********Optimization Result***************");
             writer.write(bestFinal.toString());
         } catch (IOException e) {
-            throw new GeneticException(e);
+            throw new RuntimeException(e);
         }
     }
 
-    /**
-     * Generates the initial population.
-     * @return initial population
-     */
-    private static Population getInitialPopulation() {
-        final Population population = new ElitisticListPopulation(Constants.POPULATION_SIZE_PER_DIMENSION,
-                Constants.ELITISM_RATE);
-        for (int i = 0; i < Constants.POPULATION_SIZE_PER_DIMENSION; i++) {
-            population.addChromosome(new LegacyBinaryChromosome(BinaryChromosome
-                    .randomBinaryRepresentation(DIMENSION * Constants.CHROMOSOME_LENGTH_PER_DIMENSION)));
+    private static Population getInitialPopulation(int dimension, int populationSize, double elitismRate) {
+        final Population population = new ElitisticListPopulation(populationSize, elitismRate);
+        for (int i = 0; i < populationSize; i++) {
+            population.addChromosome(new LegacyBinaryChromosome(
+                    BinaryChromosome.randomBinaryRepresentation(dimension * CHROMOSOME_LENGTH_PER_DIMENSION)));
         }
         return population;
     }
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/StandAlone.java b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/StandAlone.java
new file mode 100644
index 0000000..47bb1cf
--- /dev/null
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/StandAlone.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.commons.math4.examples.ga.mathfunctions.legacy;
+
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+@Command(name = "legacy-mathfunction-optimizer", mixinStandardHelpOptions = true,
+        version = "legacy-mathfunction-optimizer 1.0")
+public class StandAlone implements Runnable {
+
+    /** number of dimension. **/
+    @Option(names = "-d", paramLabel = "DIMENSION", required = true, description = "Dimension of problem domain.")
+    private int dimension;
+
+    /** size of tournament. **/
+    @Option(names = "-t", paramLabel = "TOURNAMENT_SIZE", required = true, description = "Tournament size.")
+    private int tournamentSize;
+
+    /** size of population. **/
+    @Option(names = "-p", paramLabel = "POPULATION_SIZE", required = true, description = "Size of population.")
+    private int populationSize;
+
+    /** rate of crossover. **/
+    @Option(names = "-c", paramLabel = "CROSSOVER_RATE", description = "Crossover rate (default: ${DEFAULT-VALUE}).")
+    private double crossoverRate = 1.0;
+
+    /** rate of elitism. **/
+    @Option(names = "-e", paramLabel = "ELITISM_RATE", description = "Elitism rate (default: ${DEFAULT-VALUE}).")
+    private double elitismRate = 0.25;
+
+    /** rate of mutation. **/
+    @Option(names = "-m", paramLabel = "MUTATION_RATE", description = "Mutation rate (default: ${DEFAULT-VALUE}).")
+    private double mutationRate = 0.01;
+
+    /** number of generations with unchanged best fitness. **/
+    @Option(names = "-g", paramLabel = "GENERATIONS_EVOLVED_WITH_UNCHANGED_BEST_FITNESS",
+            description = "No of generations evolved with unchanged best fitness (default: ${DEFAULT-VALUE}).")
+    private int generationsEvolvedWithUnchangedBestFitness = 50;
+
+    public static void main(String[] args) {
+        CommandLine.run(new StandAlone(), args);
+    }
+
+    /**
+     * This method is responsible for validating input and invoking
+     * {@link LegacyMathFunctionOptimizer}.
+     */
+    @Override
+    public void run() {
+
+        // validate all input options.
+        validateInput();
+
+        final LegacyMathFunctionOptimizer optimizer = new LegacyMathFunctionOptimizer();
+
+        optimizer.optimize(dimension, crossoverRate, mutationRate, elitismRate, tournamentSize,
+                generationsEvolvedWithUnchangedBestFitness, populationSize);
+
+    }
+
+    private void validateInput() {
+        if (this.dimension < 1) {
+            throw new IllegalArgumentException("Dimension should be greater than 0.");
+        }
+        if (this.tournamentSize < 1) {
+            throw new IllegalArgumentException("Tournament size should be greater than 1.");
+        }
+        if (populationSize < 2) {
+            throw new IllegalArgumentException("Population size should be greater than 9.");
+        }
+        if (crossoverRate > 1) {
+            throw new IllegalArgumentException("Crossover rate should be <= 1.");
+        }
+        if (elitismRate >= 1) {
+            throw new IllegalArgumentException("Elitism rate should be < 1.");
+        }
+        if (mutationRate > 1) {
+            throw new IllegalArgumentException("Mutation rate should be <= 1.");
+        }
+        if (generationsEvolvedWithUnchangedBestFitness < 1) {
+            throw new IllegalArgumentException(
+                    "Number of generations evolved with unchanged best fitness should be >= 1.");
+        }
+    }
+}
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/UnchangedBestFitness.java b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/UnchangedBestFitness.java
similarity index 96%
rename from commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/UnchangedBestFitness.java
rename to commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/UnchangedBestFitness.java
index 8800f39..eabb11d 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/UnchangedBestFitness.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/UnchangedBestFitness.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math4.examples.ga.mathfunctions.dimension2.legacy;
+package org.apache.commons.math4.examples.ga.mathfunctions.legacy;
 
 import org.apache.commons.math3.genetics.Population;
 import org.apache.commons.math3.genetics.StoppingCondition;
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/utils/package-info.java b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/package-info.java
similarity index 92%
rename from commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/utils/package-info.java
rename to commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/package-info.java
index 360a1c3..24ca3d7 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/utils/package-info.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions-legacy/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/legacy/package-info.java
@@ -17,4 +17,4 @@
 /**
  * This package provides Genetic Algorithms components and implementations.
  */
-package org.apache.commons.math4.examples.ga.mathfunctions.utils;
+package org.apache.commons.math4.examples.ga.mathfunctions.legacy;
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/pom.xml b/commons-math-examples/examples-ga/examples-ga-math-functions/pom.xml
index d09ca3f..aa2f8af 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/pom.xml
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions/pom.xml
@@ -1,14 +1,20 @@
 <?xml version="1.0"?>
-<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
-    license agreements. See the NOTICE file distributed with this work for additional 
-    information regarding copyright ownership. The ASF licenses this file to 
-    You 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. -->
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -33,12 +39,22 @@
         <math.parent.dir>${basedir}/../../..</math.parent.dir>
 
         <uberjar.name>examples-ga-mathfunctions</uberjar.name>
-        <project.mainClass>org.apache.commons.math4.examples.ga.mathfunctions.Dimension2FunctionOptimizer</project.mainClass>
+        <project.mainClass>org.apache.commons.math4.examples.ga.mathfunctions.StandAlone</project.mainClass>
         <slf4jVersion>1.7.32</slf4jVersion>
     </properties>
 
     <dependencies>
         <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-math-ga</artifactId>
+            <version>4.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jfree</groupId>
+            <artifactId>jfreechart</artifactId>
+            <version>1.5.3</version>
+        </dependency>
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-simple</artifactId>
             <version>${slf4jVersion}</version>
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimNGraphPlotter.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/ConvergenceGraphPlotter.java
similarity index 91%
rename from commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimNGraphPlotter.java
rename to commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/ConvergenceGraphPlotter.java
index 52571e3..a6aae42 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimNGraphPlotter.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/ConvergenceGraphPlotter.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math4.examples.ga.mathfunctions.dimensionN;
+package org.apache.commons.math4.examples.ga.mathfunctions;
 
 import java.awt.BorderLayout;
 import java.util.List;
@@ -39,7 +39,7 @@ import org.jfree.data.xy.XYSeriesCollection;
 /**
  * This class represents the graph plotter during optimization.
  */
-public class DimNGraphPlotter extends JFrame implements ConvergenceListener<DimensionNCoordinate> {
+public class ConvergenceGraphPlotter extends JFrame implements ConvergenceListener<Coordinate> {
 
     /**
      * Generated serialversionId.
@@ -55,7 +55,7 @@ public class DimNGraphPlotter extends JFrame implements ConvergenceListener<Dime
      * @param xAxisLabel  x axis label
      * @param yAxisLabel  y axis label
      */
-    public DimNGraphPlotter(String plotSubject, String xAxisLabel, String yAxisLabel) {
+    public ConvergenceGraphPlotter(String plotSubject, String xAxisLabel, String yAxisLabel) {
         super(plotSubject);
 
         final JPanel chartPanel = createChartPanel(plotSubject, xAxisLabel, yAxisLabel);
@@ -135,8 +135,8 @@ public class DimNGraphPlotter extends JFrame implements ConvergenceListener<Dime
      * {@inheritDoc}
      */
     @Override
-    public void notify(int generation, Population<DimensionNCoordinate> population) {
-        PopulationStatisticalSummary<DimensionNCoordinate> populationStatisticalSummary =
+    public void notify(int generation, Population<Coordinate> population) {
+        PopulationStatisticalSummary<Coordinate> populationStatisticalSummary =
                 new PopulationStatisticalSummaryImpl<>(population);
         this.addDataPoint("Average", generation, populationStatisticalSummary.getMeanFitness());
         this.addDataPoint("Best", generation, populationStatisticalSummary.getMaxFitness());
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNCoordinate.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/Coordinate.java
similarity index 89%
rename from commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNCoordinate.java
rename to commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/Coordinate.java
index 98a31bc..eee31fb 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNCoordinate.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/Coordinate.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.math4.examples.ga.mathfunctions.dimensionN;
+package org.apache.commons.math4.examples.ga.mathfunctions;
 
 import java.util.List;
 
@@ -22,7 +22,7 @@ import java.util.List;
  * This class represents the coordinate of the problem domain i.e. the phenotype
  * of chromosome.
  */
-public class DimensionNCoordinate {
+public class Coordinate {
 
     /** coordinate of all dimensions. **/
     private final List<Double> values;
@@ -31,7 +31,7 @@ public class DimensionNCoordinate {
      * constructor.
      * @param values coordinates of all dimensions.
      */
-    public DimensionNCoordinate(List<Double> values) {
+    public Coordinate(List<Double> values) {
         this.values = values;
     }
 
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2Decoder.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/CoordinateDecoder.java
similarity index 56%
rename from commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2Decoder.java
rename to commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/CoordinateDecoder.java
index e8394d1..7498266 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2Decoder.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/CoordinateDecoder.java
@@ -14,7 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.math4.examples.ga.mathfunctions.dimension2;
+package org.apache.commons.math4.examples.ga.mathfunctions;
+
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.commons.math4.ga.chromosome.BinaryChromosome;
 import org.apache.commons.math4.ga.chromosome.Chromosome;
@@ -22,28 +25,28 @@ import org.apache.commons.math4.ga.decoder.Decoder;
 
 /**
  * Decoder to convert chromosome's binary genotype to phenotype
- * {@link Dimension2Coordinate}.
+ * {@link Coordinate}.
  */
-public class Dimension2Decoder implements Decoder<Dimension2Coordinate> {
+public class CoordinateDecoder implements Decoder<Coordinate> {
 
     /**
-     * Decode the binary representation of chromosome to
-     * {@link Dimension2Coordinate}.
+     * decode the binary representation of chromosome to
+     * {@link Coordinate}.
      * @param chromosome The {@link Chromosome}
      */
     @Override
-    public Dimension2Coordinate decode(Chromosome<Dimension2Coordinate> chromosome) {
-        final BinaryChromosome<Dimension2Coordinate> binaryChromosome =
-                (BinaryChromosome<Dimension2Coordinate>) chromosome;
-        final long alleles = binaryChromosome.getRepresentation()[0];
-
-        long mask1 = ~(Long.MAX_VALUE << 12);
-        long mask2 = ~(Long.MAX_VALUE << 24) ^ mask1;
+    public Coordinate decode(Chromosome<Coordinate> chromosome) {
+        final BinaryChromosome<Coordinate> binaryChromosome =
+                (BinaryChromosome<Coordinate>) chromosome;
+        final long length = binaryChromosome.getLength();
+        final List<Double> coordinates = new ArrayList<>();
 
-        final double x = (alleles & mask1) / 100d;
-        final double y = ((alleles & mask2) >> 12) / 100d;
+        for (int i = 0; i < length; i += 12) {
+            final String dimensionStrValue = binaryChromosome.getStringRepresentation(i, i + 12);
+            coordinates.add(Integer.parseUnsignedInt(dimensionStrValue, 2) / 100d);
+        }
 
-        return new Dimension2Coordinate(x, y);
+        return new Coordinate(coordinates);
     }
 
 }
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2FitnessFunction.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/MathFunction.java
similarity index 68%
rename from commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2FitnessFunction.java
rename to commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/MathFunction.java
index 33e8f73..9e725b1 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2FitnessFunction.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/MathFunction.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math4.examples.ga.mathfunctions.dimension2;
+package org.apache.commons.math4.examples.ga.mathfunctions;
 
 import org.apache.commons.math4.ga.fitness.FitnessFunction;
 
@@ -23,18 +23,20 @@ import org.apache.commons.math4.ga.fitness.FitnessFunction;
  * This class represents the mathematical fitness function for optimizing a 2
  * dimension mathematical function.
  */
-public class Dimension2FitnessFunction implements FitnessFunction<Dimension2Coordinate> {
+public class MathFunction implements FitnessFunction<Coordinate> {
 
     /**
      * Computes the fitness value based on the decoded chromosome.
-     * @param coordinate The {@link Dimension2Coordinate}
+     * @param coordinate The {@link Coordinate}
      * @return the fitness value
      */
     @Override
-    public double compute(Dimension2Coordinate coordinate) {
-        return -Math.pow(Math.pow(coordinate.getX(), 2) + Math.pow(coordinate.getY(), 2), .25) *
-                (Math.pow(Math.sin(50 * Math.pow(Math.pow(coordinate.getX(), 2) + Math.pow(coordinate.getY(), 2), .1)),
-                        2) + 1);
+    public double compute(Coordinate coordinate) {
+        double sumOfSquare = 0.0;
+        for (Double value : coordinate.getValues()) {
+            sumOfSquare += Math.pow(value, 2);
+        }
+        return -Math.pow(sumOfSquare, .25) * (Math.pow(Math.sin(50 * Math.pow(sumOfSquare, .1)), 2) + 1);
     }
 
 }
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/MathFunctionOptimizer.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/MathFunctionOptimizer.java
new file mode 100644
index 0000000..035267a
--- /dev/null
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/MathFunctionOptimizer.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+package org.apache.commons.math4.examples.ga.mathfunctions;
+
+import org.apache.commons.math4.ga.GeneticAlgorithm;
+import org.apache.commons.math4.ga.chromosome.BinaryChromosome;
+import org.apache.commons.math4.ga.chromosome.Chromosome;
+import org.apache.commons.math4.ga.convergence.StoppingCondition;
+import org.apache.commons.math4.ga.convergence.UnchangedBestFitness;
+import org.apache.commons.math4.ga.crossover.OnePointBinaryCrossover;
+import org.apache.commons.math4.ga.mutation.BinaryMutation;
+import org.apache.commons.math4.ga.population.ListPopulation;
+import org.apache.commons.math4.ga.population.Population;
+import org.apache.commons.math4.ga.selection.TournamentSelection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class represents an optimizer for a 2-dimensional math function using
+ * genetic algorithm.
+ */
+
+public final class MathFunctionOptimizer {
+
+    /** length of chromosome. **/
+    private static final int CHROMOSOME_LENGTH_PER_DIMENSION = 12;
+
+    /** encoding for console logger. **/
+    private static final String ENCODING = "UTF-8";
+
+    /** instance of logger. **/
+    private final Logger logger = LoggerFactory.getLogger(MathFunctionOptimizer.class);
+
+    /**
+     * Optimizes the population.
+     * @param dimension                               dimension
+     * @param crossoverRate                           crossover rate
+     * @param mutationRate                            mutation rate
+     * @param elitismRate                             elitism rate
+     * @param tournamentSize                          tournament size
+     * @param generationCountWithUnchangedBestFitness no of generation evolved with
+     *                                                unchanged best fitness
+     * @param populationSize                          size of population
+     */
+    public void optimize(int dimension,
+            double crossoverRate,
+            double mutationRate,
+            double elitismRate,
+            int tournamentSize,
+            int generationCountWithUnchangedBestFitness,
+            int populationSize) {
+
+        // initialize a new genetic algorithm
+        final GeneticAlgorithm<Coordinate> ga = new GeneticAlgorithm<>(new OnePointBinaryCrossover<Coordinate>(),
+                crossoverRate, new BinaryMutation<Coordinate>(), mutationRate,
+                new TournamentSelection<>(tournamentSize), elitismRate);
+
+        // stopping condition
+        final StoppingCondition<Coordinate> stopCond = new UnchangedBestFitness<>(
+                generationCountWithUnchangedBestFitness);
+
+        // run the algorithm
+        final Population<Coordinate> finalPopulation = ga.evolve(getInitialPopulation(dimension, populationSize),
+                stopCond);
+
+        // best chromosome from the final population
+        final Chromosome<Coordinate> bestFinal = finalPopulation.getFittestChromosome();
+
+        logger.info("*********************************************");
+        logger.info("***********Optimization Result***************");
+        logger.info(bestFinal.toString());
+
+    }
+
+    private static Population<Coordinate> getInitialPopulation(int dimension, int populationSize) {
+        final Population<Coordinate> population = new ListPopulation<>(populationSize);
+        final MathFunction fitnessFunction = new MathFunction();
+        final CoordinateDecoder decoder = new CoordinateDecoder();
+        for (int i = 0; i < populationSize; i++) {
+            population.addChromosome(BinaryChromosome.<Coordinate>randomChromosome(
+                    dimension * CHROMOSOME_LENGTH_PER_DIMENSION, fitnessFunction, decoder));
+        }
+        return population;
+    }
+
+}
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/StandAlone.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/StandAlone.java
new file mode 100644
index 0000000..c096ead
--- /dev/null
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/StandAlone.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.commons.math4.examples.ga.mathfunctions;
+
+import org.apache.commons.math4.ga.internal.exception.GeneticException;
+import org.apache.commons.math4.ga.listener.ConvergenceListenerRegistry;
+import org.apache.commons.math4.ga.listener.PopulationStatisticsLogger;
+
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+@Command(name = "mathfunction-optimizer", mixinStandardHelpOptions = true, version = "mathfunction-optimizer 1.0")
+public class StandAlone implements Runnable {
+
+    /** number of dimension. **/
+    @Option(names = "-d", paramLabel = "DIMENSION", required = true, description = "Dimension of problem domain.")
+    private int dimension;
+
+    /** size of tournament. **/
+    @Option(names = "-t", paramLabel = "TOURNAMENT_SIZE", required = true, description = "Tournament size.")
+    private int tournamentSize;
+
+    /** size of population. **/
+    @Option(names = "-p", paramLabel = "POPULATION_SIZE", required = true, description = "Size of population.")
+    private int populationSize;
+
+    /** rate of crossover. **/
+    @Option(names = "-c", paramLabel = "CROSSOVER_RATE", description = "Crossover rate (default: ${DEFAULT-VALUE}).")
+    private double crossoverRate = 1.0;
+
+    /** rate of elitism. **/
+    @Option(names = "-e", paramLabel = "ELITISM_RATE", description = "Elitism rate (default: ${DEFAULT-VALUE}).")
+    private double elitismRate = 0.25;
+
+    /** rate of mutation. **/
+    @Option(names = "-m", paramLabel = "MUTATION_RATE", description = "Mutation rate (default: ${DEFAULT-VALUE}).")
+    private double mutationRate = 0.01;
+
+    /** number of generations with unchanged best fitness. **/
+    @Option(names = "-g", paramLabel = "GENERATIONS_EVOLVED_WITH_UNCHANGED_BEST_FITNESS",
+            description = "No of generations evolved with unchanged best fitness (default: ${DEFAULT-VALUE}).")
+    private int generationsEvolvedWithUnchangedBestFitness = 50;
+
+    public static void main(String[] args) {
+        CommandLine.run(new StandAlone(), args);
+    }
+
+    /**
+     * This method is responsible for validating input and then invoking math
+     * function optimizer.
+     */
+    @Override
+    public void run() {
+
+        // validate all input options.
+        validateInput();
+
+        final MathFunctionOptimizer optimizer = new MathFunctionOptimizer();
+
+        final ConvergenceListenerRegistry<Coordinate> convergenceListenerRegistry = ConvergenceListenerRegistry
+                .getInstance();
+        convergenceListenerRegistry.addConvergenceListener(new PopulationStatisticsLogger<Coordinate>());
+        convergenceListenerRegistry
+                .addConvergenceListener(new ConvergenceGraphPlotter("Convergence Stats", "generation", "fitness"));
+
+        optimizer.optimize(dimension, crossoverRate, mutationRate, elitismRate, tournamentSize,
+                generationsEvolvedWithUnchangedBestFitness, populationSize);
+
+    }
+
+    private void validateInput() {
+        if (this.dimension < 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Dimension should be > 0.");
+        }
+        if (this.tournamentSize < 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Tournament size should be > 0.");
+        }
+        if (populationSize <= 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Population size should be > 1.");
+        }
+        if (crossoverRate > 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Crossover rate should be <= 1.");
+        }
+        if (elitismRate >= 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Elitism rate should be < 1.");
+        }
+        if (mutationRate > 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, "Mutation rate should be <= 1.");
+        }
+        if (generationsEvolvedWithUnchangedBestFitness < 1) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT,
+                    "Number of generations evolved with unchanged best fitness should be >= 1.");
+        }
+    }
+}
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2FunctionAdaptiveOptimizer.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2FunctionAdaptiveOptimizer.java
deleted file mode 100644
index 6579dda..0000000
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2FunctionAdaptiveOptimizer.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.commons.math4.examples.ga.mathfunctions.dimension2;
-
-import org.apache.commons.math4.examples.ga.mathfunctions.utils.Constants;
-import org.apache.commons.math4.ga.AdaptiveGeneticAlgorithm;
-import org.apache.commons.math4.ga.chromosome.BinaryChromosome;
-import org.apache.commons.math4.ga.chromosome.Chromosome;
-import org.apache.commons.math4.ga.convergence.StoppingCondition;
-import org.apache.commons.math4.ga.convergence.UnchangedBestFitness;
-import org.apache.commons.math4.ga.crossover.OnePointBinaryCrossover;
-import org.apache.commons.math4.ga.crossover.rategenerator.ConstantCrossoverRateGenerator;
-import org.apache.commons.math4.ga.listener.ConvergenceListenerRegistry;
-import org.apache.commons.math4.ga.listener.PopulationStatisticsLogger;
-import org.apache.commons.math4.ga.mutation.BinaryMutation;
-import org.apache.commons.math4.ga.mutation.rategenerator.AdaptiveLinearMutationRateGenerator;
-import org.apache.commons.math4.ga.population.ListPopulation;
-import org.apache.commons.math4.ga.population.Population;
-import org.apache.commons.math4.ga.selection.TournamentSelection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class represents an optimizer for a 2-dimensional math function using
- * genetic algorithm.
- */
-public class Dimension2FunctionAdaptiveOptimizer {
-
-    /** number of dimension. **/
-    private static final int DIMENSION = 2;
-
-    /** size of tournament. **/
-    private static final int TOURNAMENT_SIZE = 3;
-
-    /** instance of logger. **/
-    private Logger logger = LoggerFactory.getLogger(Dimension2FunctionAdaptiveOptimizer.class);
-
-    /**
-     * Optimizes the 2-dimension fitness function.
-     * @param args arguments
-     */
-    public static void main(String[] args) {
-        final Population<Dimension2Coordinate> initPopulation = getInitialPopulation();
-
-        final Dimension2FunctionAdaptiveOptimizer optimizer = new Dimension2FunctionAdaptiveOptimizer();
-
-        final ConvergenceListenerRegistry<Dimension2Coordinate> convergenceListenerRegistry =
-                ConvergenceListenerRegistry.getInstance();
-        convergenceListenerRegistry.addConvergenceListener(new PopulationStatisticsLogger<Dimension2Coordinate>());
-        convergenceListenerRegistry
-                .addConvergenceListener(new Dim2GraphPlotter("Adaptive Convergence Stats", "generation", "fitness"));
-
-        optimizer.optimize(initPopulation);
-    }
-
-    private void optimize(Population<Dimension2Coordinate> initial) {
-
-        // initialize a new genetic algorithm
-        final AdaptiveGeneticAlgorithm<Dimension2Coordinate> ga = new AdaptiveGeneticAlgorithm<>(
-                new OnePointBinaryCrossover<Dimension2Coordinate>(), new ConstantCrossoverRateGenerator<>(1),
-                new BinaryMutation<Dimension2Coordinate>(),
-                new AdaptiveLinearMutationRateGenerator<>(Constants.AVERAGE_MUTATION_RATE / 2,
-                        Constants.AVERAGE_MUTATION_RATE * 2),
-                new TournamentSelection<>(TOURNAMENT_SIZE));
-
-        // stopping condition
-        final StoppingCondition<Dimension2Coordinate> stopCond = new UnchangedBestFitness<>(
-                Constants.GENERATION_COUNT_WITH_UNCHANGED_BEST_FUTNESS);
-
-        // run the algorithm
-        final Population<Dimension2Coordinate> finalPopulation = ga.evolve(initial, stopCond);
-
-        // best chromosome from the final population
-        final Chromosome<Dimension2Coordinate> bestFinal = finalPopulation.getFittestChromosome();
-
-        logger.info("*********************************************");
-        logger.info("***********Optimization Result***************");
-
-        logger.info(bestFinal.toString());
-
-    }
-
-    /**
-     * Generates an initial population.
-     * @return initial population
-     */
-    private static Population<Dimension2Coordinate> getInitialPopulation() {
-        final Population<Dimension2Coordinate> population = new ListPopulation<>(
-                DIMENSION * Constants.POPULATION_SIZE_PER_DIMENSION);
-        final Dimension2FitnessFunction fitnessFunction = new Dimension2FitnessFunction();
-        final Dimension2Decoder decoder = new Dimension2Decoder();
-        for (int i = 0; i < DIMENSION * Constants.POPULATION_SIZE_PER_DIMENSION; i++) {
-            population.addChromosome(BinaryChromosome.<Dimension2Coordinate>randomChromosome(
-                    DIMENSION * Constants.CHROMOSOME_LENGTH_PER_DIMENSION, fitnessFunction, decoder));
-        }
-        return population;
-    }
-
-}
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2FunctionOptimizer.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2FunctionOptimizer.java
deleted file mode 100644
index 1d6a3fa..0000000
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2FunctionOptimizer.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.commons.math4.examples.ga.mathfunctions.dimension2;
-
-import org.apache.commons.math4.examples.ga.mathfunctions.utils.Constants;
-import org.apache.commons.math4.ga.GeneticAlgorithm;
-import org.apache.commons.math4.ga.chromosome.BinaryChromosome;
-import org.apache.commons.math4.ga.chromosome.Chromosome;
-import org.apache.commons.math4.ga.convergence.StoppingCondition;
-import org.apache.commons.math4.ga.convergence.UnchangedBestFitness;
-import org.apache.commons.math4.ga.crossover.OnePointBinaryCrossover;
-import org.apache.commons.math4.ga.listener.ConvergenceListenerRegistry;
-import org.apache.commons.math4.ga.listener.PopulationStatisticsLogger;
-import org.apache.commons.math4.ga.mutation.BinaryMutation;
-import org.apache.commons.math4.ga.population.ListPopulation;
-import org.apache.commons.math4.ga.population.Population;
-import org.apache.commons.math4.ga.selection.TournamentSelection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class represents an optimizer for a 2-dimensional math function using
- * genetic algorithm.
- */
-public class Dimension2FunctionOptimizer {
-
-    /** number of dimension. **/
-    private static final int DIMENSION = 2;
-
-    /** size of tournament. **/
-    private static final int TOURNAMENT_SIZE = 3;
-
-    /** instance of logger. **/
-    private Logger logger = LoggerFactory.getLogger(Dimension2FunctionAdaptiveOptimizer.class);
-
-    /**
-     * Optimizes the 2-dimension fitness function.
-     * @param args arguments
-     */
-    public static void main(String[] args) {
-        final Population<Dimension2Coordinate> initPopulation = getInitialPopulation();
-
-        final Dimension2FunctionOptimizer optimizer = new Dimension2FunctionOptimizer();
-
-        final ConvergenceListenerRegistry<Dimension2Coordinate> convergenceListenerRegistry =
-                ConvergenceListenerRegistry.getInstance();
-        convergenceListenerRegistry.addConvergenceListener(new PopulationStatisticsLogger<Dimension2Coordinate>());
-        convergenceListenerRegistry
-                .addConvergenceListener(new Dim2GraphPlotter("Convergence Stats", "generation", "fitness"));
-
-        optimizer.optimize(initPopulation);
-    }
-
-    /**
-     * Optimizes the population.
-     * @param initial The {@link Population}
-     */
-    public void optimize(Population<Dimension2Coordinate> initial) {
-
-        // initialize a new genetic algorithm
-        final GeneticAlgorithm<Dimension2Coordinate> ga = new GeneticAlgorithm<>(
-                new OnePointBinaryCrossover<Dimension2Coordinate>(), Constants.CROSSOVER_RATE,
-                new BinaryMutation<Dimension2Coordinate>(), Constants.AVERAGE_MUTATION_RATE,
-                new TournamentSelection<Dimension2Coordinate>(TOURNAMENT_SIZE), Constants.ELITISM_RATE);
-
-        // stopping condition
-        final StoppingCondition<Dimension2Coordinate> stopCond = new UnchangedBestFitness<>(
-                Constants.GENERATION_COUNT_WITH_UNCHANGED_BEST_FUTNESS);
-
-        // run the algorithm
-        final Population<Dimension2Coordinate> finalPopulation = ga.evolve(initial, stopCond);
-
-        // best chromosome from the final population
-        final Chromosome<Dimension2Coordinate> bestFinal = finalPopulation.getFittestChromosome();
-
-        logger.info("*********************************************");
-        logger.info("***********Optimization Result***************");
-
-        logger.info(bestFinal.toString());
-
-    }
-
-    /**
-     * Generates an initial population.
-     * @return initial population
-     */
-    private static Population<Dimension2Coordinate> getInitialPopulation() {
-        final Population<Dimension2Coordinate> population = new ListPopulation<>(
-                DIMENSION * Constants.POPULATION_SIZE_PER_DIMENSION);
-        final Dimension2FitnessFunction fitnessFunction = new Dimension2FitnessFunction();
-        final Dimension2Decoder decoder = new Dimension2Decoder();
-        for (int i = 0; i < DIMENSION * Constants.POPULATION_SIZE_PER_DIMENSION; i++) {
-            population.addChromosome(BinaryChromosome.<Dimension2Coordinate>randomChromosome(
-                    DIMENSION * Constants.CHROMOSOME_LENGTH_PER_DIMENSION, fitnessFunction, decoder));
-        }
-        return population;
-    }
-
-}
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/package-info.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/package-info.java
deleted file mode 100644
index 7965791..0000000
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/legacy/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-/**
- * This package provides Genetic Algorithms components and implementations.
- */
-package org.apache.commons.math4.examples.ga.mathfunctions.dimension2.legacy;
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/package-info.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/package-info.java
deleted file mode 100644
index 432651f..0000000
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-/**
- * This package provides Genetic Algorithms components and implementations.
- */
-package org.apache.commons.math4.examples.ga.mathfunctions.dimension2;
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNFunctionAdaptiveOptimizer.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNFunctionAdaptiveOptimizer.java
deleted file mode 100644
index dee317a..0000000
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNFunctionAdaptiveOptimizer.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.commons.math4.examples.ga.mathfunctions.dimensionN;
-
-import org.apache.commons.math4.examples.ga.mathfunctions.utils.Constants;
-import org.apache.commons.math4.ga.AbstractGeneticAlgorithm;
-import org.apache.commons.math4.ga.AdaptiveGeneticAlgorithm;
-import org.apache.commons.math4.ga.chromosome.BinaryChromosome;
-import org.apache.commons.math4.ga.chromosome.Chromosome;
-import org.apache.commons.math4.ga.convergence.StoppingCondition;
-import org.apache.commons.math4.ga.convergence.UnchangedBestFitness;
-import org.apache.commons.math4.ga.crossover.OnePointBinaryCrossover;
-import org.apache.commons.math4.ga.crossover.rategenerator.AdaptiveLinearMaximumRankBasedCrossoverRateGenerator;
-import org.apache.commons.math4.ga.listener.ConvergenceListenerRegistry;
-import org.apache.commons.math4.ga.listener.PopulationStatisticsLogger;
-import org.apache.commons.math4.ga.mutation.BinaryMutation;
-import org.apache.commons.math4.ga.mutation.rategenerator.AdaptiveLinearMutationRateGenerator;
-import org.apache.commons.math4.ga.population.ListPopulation;
-import org.apache.commons.math4.ga.population.Population;
-import org.apache.commons.math4.ga.selection.TournamentSelection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class represents an optimizer for a 2-dimensional math function using
- * genetic algorithm.
- */
-public class DimensionNFunctionAdaptiveOptimizer {
-
-    /** number of dimension. **/
-    private static final int DIMENSION = 10;
-
-    /** size of tournament. **/
-    private static final int TOURNAMENT_SIZE = 4;
-
-    /** instance of logger. **/
-    private Logger logger = LoggerFactory.getLogger(DimensionNFunctionOptimizer.class);
-
-    /**
-     * Optimizes the 2-dimension fitness function.
-     * @param args arguments
-     */
-    public static void main(String[] args) {
-        final Population<DimensionNCoordinate> initPopulation = getInitialPopulation();
-
-        final DimensionNFunctionAdaptiveOptimizer optimizer = new DimensionNFunctionAdaptiveOptimizer();
-
-        final ConvergenceListenerRegistry<DimensionNCoordinate> convergenceListenerRegistry =
-                ConvergenceListenerRegistry.getInstance();
-        convergenceListenerRegistry.addConvergenceListener(new PopulationStatisticsLogger<DimensionNCoordinate>());
-        convergenceListenerRegistry
-                .addConvergenceListener(new DimNGraphPlotter("Adaptive Convergence Stats", "generation", "fitness"));
-
-        optimizer.optimize(initPopulation);
-    }
-
-    private void optimize(Population<DimensionNCoordinate> initial) {
-
-        // initialize a new genetic algorithm
-        final AbstractGeneticAlgorithm<DimensionNCoordinate> ga = new AdaptiveGeneticAlgorithm<DimensionNCoordinate>(
-                new OnePointBinaryCrossover<DimensionNCoordinate>(),
-                new AdaptiveLinearMaximumRankBasedCrossoverRateGenerator<>(Constants.CROSSOVER_RATE / 2,
-                        Constants.CROSSOVER_RATE),
-                new BinaryMutation<>(), new AdaptiveLinearMutationRateGenerator<>(0, Constants.AVERAGE_MUTATION_RATE),
-                new TournamentSelection<>(TOURNAMENT_SIZE), Constants.ELITISM_RATE);
-
-        // stopping condition
-        final StoppingCondition<DimensionNCoordinate> stopCond = new UnchangedBestFitness<>(
-                Constants.GENERATION_COUNT_WITH_UNCHANGED_BEST_FUTNESS);
-
-        // run the algorithm
-        final Population<DimensionNCoordinate> finalPopulation = ga.evolve(initial, stopCond);
-
-        // best chromosome from the final population
-        final Chromosome<DimensionNCoordinate> bestFinal = finalPopulation.getFittestChromosome();
-
-        logger.info("*********************************************");
-        logger.info("***********Optimization Result***************");
-        logger.info(bestFinal.toString());
-
-    }
-
-    /**
-     * Generates an initial population.
-     * @return initial population
-     */
-    private static Population<DimensionNCoordinate> getInitialPopulation() {
-        final Population<DimensionNCoordinate> population = new ListPopulation<>(
-                DIMENSION * Constants.POPULATION_SIZE_PER_DIMENSION);
-        final DimensionNFitnessFunction fitnessFunction = new DimensionNFitnessFunction();
-        final DimensionNDecoder decoder = new DimensionNDecoder();
-        for (int i = 0; i < DIMENSION * Constants.POPULATION_SIZE_PER_DIMENSION; i++) {
-            population.addChromosome(BinaryChromosome.<DimensionNCoordinate>randomChromosome(
-                    DIMENSION * Constants.CHROMOSOME_LENGTH_PER_DIMENSION, fitnessFunction, decoder));
-        }
-        return population;
-    }
-
-}
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNFunctionOptimizer.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNFunctionOptimizer.java
deleted file mode 100644
index 5791b05..0000000
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/DimensionNFunctionOptimizer.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.commons.math4.examples.ga.mathfunctions.dimensionN;
-
-import org.apache.commons.math4.examples.ga.mathfunctions.utils.Constants;
-import org.apache.commons.math4.ga.GeneticAlgorithm;
-import org.apache.commons.math4.ga.chromosome.BinaryChromosome;
-import org.apache.commons.math4.ga.chromosome.Chromosome;
-import org.apache.commons.math4.ga.convergence.StoppingCondition;
-import org.apache.commons.math4.ga.convergence.UnchangedBestFitness;
-import org.apache.commons.math4.ga.crossover.OnePointBinaryCrossover;
-import org.apache.commons.math4.ga.listener.ConvergenceListenerRegistry;
-import org.apache.commons.math4.ga.listener.PopulationStatisticsLogger;
-import org.apache.commons.math4.ga.mutation.BinaryMutation;
-import org.apache.commons.math4.ga.population.ListPopulation;
-import org.apache.commons.math4.ga.population.Population;
-import org.apache.commons.math4.ga.selection.TournamentSelection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class represents an optimizer for a 2-dimensional math function using
- * genetic algorithm.
- */
-public class DimensionNFunctionOptimizer {
-
-    /** number of dimension. **/
-    private static final int DIMENSION = 10;
-
-    /** size of tournament. **/
-    private static final int TOURNAMENT_SIZE = 4;
-
-    /** instance of logger. **/
-    private Logger logger = LoggerFactory.getLogger(DimensionNFunctionOptimizer.class);
-
-    /**
-     * Optimizes the 2-dimension fitness function.
-     * @param args arguments
-     */
-    public static void main(String[] args) {
-        final Population<DimensionNCoordinate> initPopulation = getInitialPopulation();
-
-        final DimensionNFunctionOptimizer optimizer = new DimensionNFunctionOptimizer();
-
-        final ConvergenceListenerRegistry<DimensionNCoordinate> convergenceListenerRegistry =
-                ConvergenceListenerRegistry.getInstance();
-        convergenceListenerRegistry.addConvergenceListener(new PopulationStatisticsLogger<DimensionNCoordinate>());
-        convergenceListenerRegistry
-                .addConvergenceListener(new DimNGraphPlotter("Convergence Stats", "generation", "fitness"));
-
-        optimizer.optimize(initPopulation);
-    }
-
-    /**
-     * Optimizes the population.
-     * @param initial The {@link Population}
-     */
-    public void optimize(Population<DimensionNCoordinate> initial) {
-
-        // initialize a new genetic algorithm
-        final GeneticAlgorithm<DimensionNCoordinate> ga = new GeneticAlgorithm<>(
-                new OnePointBinaryCrossover<DimensionNCoordinate>(), Constants.CROSSOVER_RATE,
-                new BinaryMutation<DimensionNCoordinate>(), Constants.AVERAGE_MUTATION_RATE,
-                new TournamentSelection<>(TOURNAMENT_SIZE), Constants.ELITISM_RATE);
-
-        // stopping condition
-        final StoppingCondition<DimensionNCoordinate> stopCond = new UnchangedBestFitness<>(
-                Constants.GENERATION_COUNT_WITH_UNCHANGED_BEST_FUTNESS);
-
-        // run the algorithm
-        final Population<DimensionNCoordinate> finalPopulation = ga.evolve(initial, stopCond);
-
-        // best chromosome from the final population
-        final Chromosome<DimensionNCoordinate> bestFinal = finalPopulation.getFittestChromosome();
-
-        logger.info("*********************************************");
-        logger.info("***********Optimization Result***************");
-        logger.info(bestFinal.toString());
-
-    }
-
-    /**
-     * Generates an initial population.
-     * @return initial population
-     */
-    private static Population<DimensionNCoordinate> getInitialPopulation() {
-        final Population<DimensionNCoordinate> population = new ListPopulation<>(
-                DIMENSION * Constants.POPULATION_SIZE_PER_DIMENSION);
-        final DimensionNFitnessFunction fitnessFunction = new DimensionNFitnessFunction();
-        final DimensionNDecoder decoder = new DimensionNDecoder();
-        for (int i = 0; i < DIMENSION * Constants.POPULATION_SIZE_PER_DIMENSION; i++) {
-            population.addChromosome(BinaryChromosome.<DimensionNCoordinate>randomChromosome(
-                    DIMENSION * Constants.CHROMOSOME_LENGTH_PER_DIMENSION, fitnessFunction, decoder));
-        }
-        return population;
-    }
-
-}
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/package-info.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/package-info.java
deleted file mode 100644
index 6a15fed..0000000
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimensionN/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-/**
- * This package provides Genetic Algorithms components and implementations.
- */
-package org.apache.commons.math4.examples.ga.mathfunctions.dimensionN;
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons/package-info.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/package-info.java
similarity index 93%
rename from commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons/package-info.java
rename to commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/package-info.java
index e0422fd..f2344be 100644
--- a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons/package-info.java
+++ b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/package-info.java
@@ -17,4 +17,4 @@
 /**
  * This package provides Genetic Algorithms components and implementations.
  */
-package org.apache.commons.math4.examples.ga.tsp.commons;
+package org.apache.commons.math4.examples.ga.mathfunctions;
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/utils/Constants.java b/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/utils/Constants.java
deleted file mode 100644
index 1389c75..0000000
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/utils/Constants.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-package org.apache.commons.math4.examples.ga.mathfunctions.utils;
-
-/**
- * This abstraction maintains constants used by this module.
- */
-public final class Constants {
-
-    /** size of population. **/
-    public static final int POPULATION_SIZE_PER_DIMENSION = 10;
-
-    /** size of tournament. **/
-    public static final int TOURNAMENT_SIZE_PER_DIMENSION = 2;
-
-    /** length of chromosome. **/
-    public static final int CHROMOSOME_LENGTH_PER_DIMENSION = 12;
-
-    /** rate of crossover. **/
-    public static final double CROSSOVER_RATE = 1.0;
-
-    /** rate of elitism. **/
-    public static final double ELITISM_RATE = 0.25;
-
-    /** rate of mutation. **/
-    public static final double AVERAGE_MUTATION_RATE = 0.05;
-
-    /** number of generations with unchanged best fitness. **/
-    public static final int GENERATION_COUNT_WITH_UNCHANGED_BEST_FUTNESS = 50;
-
-    /** encoding for console logger. **/
-    public static final String ENCODING = "UTF-8";
-
-    /**
-     * constructor.
-     */
-    private Constants() {
-
-    }
-
-}
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp-legacy/LICENCE b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/LICENCE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/LICENCE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp-legacy/NOTICE b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/NOTICE
new file mode 100644
index 0000000..28031e8
--- /dev/null
+++ b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/NOTICE
@@ -0,0 +1,5 @@
+Apache Commons Math
+Copyright 2001-2022 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/commons-math-examples/examples-ga/pom.xml b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/pom.xml
similarity index 61%
copy from commons-math-examples/examples-ga/pom.xml
copy to commons-math-examples/examples-ga/examples-ga-tsp-legacy/pom.xml
index 8432483..65f8dbc 100644
--- a/commons-math-examples/examples-ga/pom.xml
+++ b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/pom.xml
@@ -21,36 +21,36 @@
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.commons</groupId>
-        <artifactId>commons-math-examples</artifactId>
+        <artifactId>examples-ga</artifactId>
         <version>4.0-SNAPSHOT</version>
     </parent>
-    <artifactId>examples-ga</artifactId>
-    <packaging>pom</packaging>
-    <name>examples-genetic-algorithm</name>
-
+    <artifactId>examples-ga-tsp-legacy</artifactId>
     <properties>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+
+        <!-- OSGi -->
+        <commons.osgi.symbolicName>org.apache.commons.math4.examples.ga.tsp.legacy</commons.osgi.symbolicName>
+        <commons.osgi.export>org.apache.commons.math4.examples.ga.tsp.legacy</commons.osgi.export>
+        <!-- Java 9+ -->
+        <commons.automatic.module.name>org.apache.commons.math4.examples.ga.tsp.legacy</commons.automatic.module.name>
         <!-- Workaround to avoid duplicating config files. -->
-        <math.parent.dir>${basedir}/../..</math.parent.dir>
+        <math.parent.dir>${basedir}/../../..</math.parent.dir>
+
+        <uberjar.name>examples-ga-tsp-legacy</uberjar.name>
+        <project.mainClass>org.apache.commons.math4.examples.ga.tsp.legacy.StandAlone</project.mainClass>
+        <slf4jVersion>1.7.32</slf4jVersion>
     </properties>
 
     <dependencies>
         <dependency>
             <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math-ga</artifactId>
-            <version>4.0-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
             <artifactId>commons-math3</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.jfree</groupId>
-            <artifactId>jfreechart</artifactId>
-            <version>1.5.3</version>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-csv</artifactId>
+            <version>1.9.0</version>
         </dependency>
     </dependencies>
-    <modules>
-        <module>examples-ga-math-functions</module>
-        <module>examples-ga-tsp</module>
-    </modules>
 </project>
\ No newline at end of file
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons/City.java b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/City.java
similarity index 96%
rename from commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons/City.java
rename to commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/City.java
index 7a6d8d1..25f5e24 100644
--- a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons/City.java
+++ b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/City.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.math4.examples.ga.tsp.commons;
+package org.apache.commons.math4.examples.ga.tsp.legacy;
 
 /**
  * This class represents a city with location coordinate.
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons/DistanceMatrix.java b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/DistanceMatrix.java
similarity index 82%
copy from commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons/DistanceMatrix.java
copy to commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/DistanceMatrix.java
index 175c7c6..a028068 100644
--- a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons/DistanceMatrix.java
+++ b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/DistanceMatrix.java
@@ -14,25 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.math4.examples.ga.tsp.commons;
+package org.apache.commons.math4.examples.ga.tsp.legacy;
 
 import java.util.List;
 
-import org.apache.commons.math4.examples.ga.tsp.utils.Constants;
-
 /**
  * This class represents the distance matrix between cities.
  */
 public final class DistanceMatrix {
 
     /** instance of the class. **/
-    private static final DistanceMatrix INSTANCE = new DistanceMatrix();
+    private static DistanceMatrix instance;
 
     /** distances between cities. **/
     private double[][] distances;
 
-    private DistanceMatrix() {
-        initialize(Constants.CITIES);
+    private DistanceMatrix(List<City> cities) {
+        initialize(cities);
     }
 
     /**
@@ -62,10 +60,14 @@ public final class DistanceMatrix {
 
     /**
      * Returns the instance of this class.
+     * @param cities the cities
      * @return instance
      */
-    public static DistanceMatrix getInstance() {
-        return INSTANCE;
+    public static synchronized DistanceMatrix getInstance(List<City> cities) {
+        if (instance == null) {
+            instance = new DistanceMatrix(cities);
+        }
+        return instance;
     }
 
 }
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/TSPOptimizerLegacy.java b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/LegacyTSPOptimizer.java
similarity index 62%
rename from commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/TSPOptimizerLegacy.java
rename to commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/LegacyTSPOptimizer.java
index 81ae597..c6059b3 100644
--- a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/TSPOptimizerLegacy.java
+++ b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/LegacyTSPOptimizer.java
@@ -17,7 +17,6 @@
 package org.apache.commons.math4.examples.ga.tsp.legacy;
 
 import java.io.BufferedWriter;
-
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.util.List;
@@ -30,66 +29,64 @@ import org.apache.commons.math3.genetics.RandomKey;
 import org.apache.commons.math3.genetics.RandomKeyMutation;
 import org.apache.commons.math3.genetics.StoppingCondition;
 import org.apache.commons.math3.genetics.TournamentSelection;
-import org.apache.commons.math4.examples.ga.tsp.commons.City;
-import org.apache.commons.math4.examples.ga.tsp.utils.Constants;
-import org.apache.commons.math4.ga.internal.exception.GeneticException;
 
 /**
  * This class represents the tsp optimizer based on legacy implementation of
  * Genetic Algorithm.
  */
-public class TSPOptimizerLegacy {
-
-    /**
-     * MainThread.sleep(5000) method to initiate optimization.
-     * @param args arguments
-     */
-    public static void main(String[] args) {
+public class LegacyTSPOptimizer {
 
-        final Population initPopulation = getInitialPopulation(Constants.CITIES);
-        final TSPOptimizerLegacy optimizer = new TSPOptimizerLegacy();
-
-        optimizer.optimize(initPopulation, Constants.CITIES);
-
-    }
+    /** encoding for console logger. **/
+    public static final String ENCODING = "UTF-8";
 
     /**
-     * Optimizes the tsp problem using legacy GA.
-     * @param initial initial population
-     * @param cities  cities
+     * Optimizes the TSP problem.
+     * @param cities                                  list of cities
+     * @param crossoverRate                           rate of crossover
+     * @param mutationRate                            rate of mutation
+     * @param elitismRate                             rate of elitism
+     * @param tournamentSize                          size of tournament
+     * @param generationCountWithUnchangedBestFitness no of generations evolved with
+     *                                                unchanged best fitness
+     * @param populationSize                          size of population
      */
-    public void optimize(Population initial, List<City> cities) {
+    public void optimize(List<City> cities,
+            double crossoverRate,
+            double mutationRate,
+            double elitismRate,
+            int tournamentSize,
+            int generationCountWithUnchangedBestFitness,
+            int populationSize) {
 
         // initialize a new genetic algorithm
-        final GeneticAlgorithm ga = new GeneticAlgorithm(new OnePointCrossover<Integer>(), Constants.CROSSOVER_RATE,
-                new RandomKeyMutation(), Constants.AVERAGE_MUTATION_RATE,
-                new TournamentSelection(Constants.TOURNAMENT_SIZE));
+        final GeneticAlgorithm ga = new GeneticAlgorithm(new OnePointCrossover<Integer>(), crossoverRate,
+                new RandomKeyMutation(), mutationRate, new TournamentSelection(tournamentSize));
 
         // stopping condition
-        final StoppingCondition stopCond = new UnchangedBestFitness(
-                Constants.GENERATION_COUNT_WITH_UNCHANGED_BEST_FUTNESS);
+        final StoppingCondition stopCond = new UnchangedBestFitness(generationCountWithUnchangedBestFitness);
 
         // run the algorithm
-        final Population finalPopulation = ga.evolve(initial, stopCond);
+        final Population finalPopulation = ga.evolve(getInitialPopulation(cities, populationSize, elitismRate),
+                stopCond);
 
         // best chromosome from the final population
         @SuppressWarnings("unchecked")
         final RandomKey<City> bestFinal = (RandomKey<City>) finalPopulation.getFittestChromosome();
 
-        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out, Constants.ENCODING))) {
+        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out, ENCODING))) {
             writer.write("*********************************************");
             writer.newLine();
             writer.write("***********Optimization Result***************");
             writer.write(bestFinal.toString());
         } catch (IOException e) {
-            throw new GeneticException(e);
+            throw new RuntimeException(e);
         }
     }
 
-    private static Population getInitialPopulation(List<City> cities) {
-        final Population simulationPopulation = new ElitisticListPopulation(Constants.POPULATION_SIZE, .25);
+    private static Population getInitialPopulation(List<City> cities, int populationSize, double elitismRate) {
+        final Population simulationPopulation = new ElitisticListPopulation(populationSize, elitismRate);
 
-        for (int i = 0; i < Constants.POPULATION_SIZE; i++) {
+        for (int i = 0; i < populationSize; i++) {
             simulationPopulation.addChromosome(new TSPChromosome(RandomKey.randomPermutation(cities.size()), cities));
         }
 
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/StandAlone.java b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/StandAlone.java
new file mode 100644
index 0000000..12f12ee
--- /dev/null
+++ b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/StandAlone.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.commons.math4.examples.ga.tsp.legacy;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+@Command(name = "legacy-tsp-optimizer", mixinStandardHelpOptions = true, version = "legacy-tsp-optimizer 1.0")
+public class StandAlone implements Runnable {
+
+    /** list of cities. **/
+    public static final List<City> CITIES = Collections.unmodifiableList(
+            Arrays.asList(new City[] {new City(1, 0, 0), new City(2, 1, 0), new City(3, 2, 0), new City(4, 3, 0),
+                new City(5, 3, 1), new City(6, 3, 2), new City(7, 3, 3), new City(8, 2, 3), new City(9, 1, 3),
+                new City(10, 0, 3), new City(11, 1, 2), new City(12, 2, 2), new City(13, 2, 1), new City(14, 1, 1)}));
+
+    /** size of tournament. **/
+    @Option(names = "-t", paramLabel = "TOURNAMENT_SIZE", required = true, description = "Tournament size.")
+    private int tournamentSize;
+
+    /** size of population. **/
+    @Option(names = "-p", paramLabel = "POPULATION_SIZE", required = true, description = "Size of population.")
+    private int populationSize;
+
+    /** rate of crossover. **/
+    @Option(names = "-c", paramLabel = "CROSSOVER_RATE", description = "Crossover rate (default: ${DEFAULT-VALUE}).")
+    private double crossoverRate = 1.0;
+
+    /** rate of elitism. **/
+    @Option(names = "-e", paramLabel = "ELITISM_RATE", description = "Elitism rate (default: ${DEFAULT-VALUE}).")
+    private double elitismRate = 0.25;
+
+    /** rate of mutation. **/
+    @Option(names = "-m", paramLabel = "MUTATION_RATE", description = "Mutation rate (default: ${DEFAULT-VALUE}).")
+    private double mutationRate = 0.01;
+
+    /** number of generations with unchanged best fitness. **/
+    @Option(names = "-g", paramLabel = "GENERATIONS_EVOLVED_WITH_UNCHANGED_BEST_FITNESS",
+            description = "No of generations evolved with unchanged best fitness (default: ${DEFAULT-VALUE}).")
+    private int generationsEvolvedWithUnchangedBestFitness = 50;
+
+    public static void main(String[] args) {
+        CommandLine.run(new StandAlone(), args);
+    }
+
+    /**
+     * This method is responsible for validating input and invoking
+     * {@link LegacyTSPOptimizer}.
+     */
+    @Override
+    public void run() {
+
+        // validate all input options.
+        validateInput();
+
+        final LegacyTSPOptimizer optimizer = new LegacyTSPOptimizer();
+
+        optimizer.optimize(CITIES, crossoverRate, mutationRate, elitismRate, tournamentSize,
+                generationsEvolvedWithUnchangedBestFitness, populationSize);
+
+    }
+
+    private void validateInput() {
+        if (this.tournamentSize < 1) {
+            throw new IllegalArgumentException("Tournament size should be > 0.");
+        }
+        if (populationSize < 2) {
+            throw new IllegalArgumentException("Population size should be > 1.");
+        }
+        if (crossoverRate > 1) {
+            throw new IllegalArgumentException("Crossover rate should be <= 1.");
+        }
+        if (elitismRate >= 1) {
+            throw new IllegalArgumentException("Elitism rate should be < 1.");
+        }
+        if (mutationRate > 1) {
+            throw new IllegalArgumentException("Mutation rate should be <= 1.");
+        }
+        if (generationsEvolvedWithUnchangedBestFitness < 1) {
+            throw new IllegalArgumentException(
+                    "Number of generations evolved with unchanged best fitness should be >= 1.");
+        }
+    }
+}
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/TSPChromosome.java b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/TSPChromosome.java
similarity index 84%
rename from commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/TSPChromosome.java
rename to commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/TSPChromosome.java
index 9a42d39..184907f 100644
--- a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/TSPChromosome.java
+++ b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/TSPChromosome.java
@@ -19,8 +19,6 @@ package org.apache.commons.math4.examples.ga.tsp.legacy;
 import java.util.List;
 
 import org.apache.commons.math3.genetics.RandomKey;
-import org.apache.commons.math4.examples.ga.tsp.commons.City;
-import org.apache.commons.math4.examples.ga.tsp.commons.DistanceMatrix;
 
 /**
  * This class represents chromosome for tsp problem.
@@ -58,19 +56,16 @@ public class TSPChromosome extends RandomKey<City> {
     }
 
     private double calculateTotalDistance(List<City> permutedCities) {
+        final DistanceMatrix distanceMatrix = DistanceMatrix.getInstance(permutedCities);
         double totalDistance = 0.0;
         int index1 = 0;
         int index2 = 0;
         for (int i = 0; i < permutedCities.size(); i++) {
             index1 = i;
             index2 = (i == permutedCities.size() - 1) ? 0 : i + 1;
-            totalDistance += calculateNodeDistance(permutedCities.get(index1), permutedCities.get(index2));
+            totalDistance += distanceMatrix.getDistance(permutedCities.get(index1), permutedCities.get(index2));
         }
         return totalDistance;
     }
 
-    private double calculateNodeDistance(City node1, City node2) {
-        return DistanceMatrix.getInstance().getDistance(node1, node2);
-    }
-
 }
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/UnchangedBestFitness.java b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/UnchangedBestFitness.java
similarity index 100%
rename from commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/UnchangedBestFitness.java
rename to commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/UnchangedBestFitness.java
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/package-info.java b/commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/package-info.java
similarity index 100%
rename from commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/package-info.java
rename to commons-math-examples/examples-ga/examples-ga-tsp-legacy/src/main/java/org/apache/commons/math4/examples/ga/tsp/legacy/package-info.java
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/pom.xml b/commons-math-examples/examples-ga/examples-ga-tsp/pom.xml
index b4a7811..f42dd22 100644
--- a/commons-math-examples/examples-ga/examples-ga-tsp/pom.xml
+++ b/commons-math-examples/examples-ga/examples-ga-tsp/pom.xml
@@ -1,14 +1,20 @@
 <?xml version="1.0"?>
-<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
-    license agreements. See the NOTICE file distributed with this work for additional 
-    information regarding copyright ownership. The ASF licenses this file to 
-    You 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. -->
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -32,14 +38,24 @@
         <!-- Workaround to avoid duplicating config files. -->
         <math.parent.dir>${basedir}/../../..</math.parent.dir>
 
-        <uberjar.name>examples-ga-mathfunctions</uberjar.name>
-        <project.mainClass>org.apache.commons.math4.examples.ga.tsp.TSPOptimizer</project.mainClass>
+        <uberjar.name>examples-ga-tsp</uberjar.name>
+        <project.mainClass>org.apache.commons.math4.examples.ga.tsp.StandAlone</project.mainClass>
         <slf4jVersion>1.7.32</slf4jVersion>
     </properties>
 
     <dependencies>
         <dependency>
             <groupId>org.apache.commons</groupId>
+            <artifactId>commons-math-ga</artifactId>
+            <version>4.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jfree</groupId>
+            <artifactId>jfreechart</artifactId>
+            <version>1.5.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
             <artifactId>commons-csv</artifactId>
             <version>1.9.0</version>
         </dependency>
diff --git a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2Coordinate.java b/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/City.java
similarity index 60%
rename from commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2Coordinate.java
rename to commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/City.java
index 307f1ef..ced4c91 100644
--- a/commons-math-examples/examples-ga/examples-ga-math-functions/src/main/java/org/apache/commons/math4/examples/ga/mathfunctions/dimension2/Dimension2Coordinate.java
+++ b/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/City.java
@@ -14,51 +14,64 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.math4.examples.ga.mathfunctions.dimension2;
+package org.apache.commons.math4.examples.ga.tsp;
 
 /**
- * This class represents the coordinate of the problem domain i.e. the phenotype of chromosome.
+ * This class represents a city with location coordinate.
  */
-public class Dimension2Coordinate {
+public final class City {
 
-    /** coordinate of first dimension. **/
+    /** index of city. **/
+    private final int index;
+
+    /** x coordinate. **/
     private final double x;
 
-    /** coordinate of second dimension. **/
+    /** y coordinate. **/
     private final double y;
 
     /**
      * constructor.
-     * @param x coordinate of first dimension
-     * @param y coordinate of second dimension
+     * @param index index of city
+     * @param x     x coordinate
+     * @param y     y coordinate
      */
-    public Dimension2Coordinate(double x, double y) {
+    public City(int index, double x, double y) {
+        this.index = index;
         this.x = x;
         this.y = y;
     }
 
     /**
-     * returns the coordinate of first dimension.
-     * @return coordinate of first dimension
+     * Returns city index.
+     * @return city index
+     */
+    public int getIndex() {
+        return index;
+    }
+
+    /**
+     * Returns x coordinate.
+     * @return x coordinate
      */
     public double getX() {
         return x;
     }
 
     /**
-     * returns the coordinate of second dimension.
-     * @return coordinate of second dimension
+     * Returns y coordinate.
+     * @return y coordinate
      */
     public double getY() {
         return y;
     }
 
     /**
-     * Returns a string representation of coordinate.
+     * {@inheritDoc}
      */
     @Override
     public String toString() {
-        return "Coordinate [x=" + x + ", y=" + y + "]";
+        return "Node [index=" + index + ", x=" + x + ", y=" + y + "]";
     }
 
 }
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/utils/GraphPlotter.java b/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/ConvergenceGraphPlotter.java
similarity index 94%
rename from commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/utils/GraphPlotter.java
rename to commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/ConvergenceGraphPlotter.java
index 701380b..1d2c454 100644
--- a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/utils/GraphPlotter.java
+++ b/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/ConvergenceGraphPlotter.java
@@ -14,16 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.math4.examples.ga.tsp.utils;
+package org.apache.commons.math4.examples.ga.tsp;
 
 import java.awt.BorderLayout;
-
 import java.util.List;
 
 import javax.swing.JFrame;
 import javax.swing.JPanel;
 
-import org.apache.commons.math4.examples.ga.tsp.commons.City;
 import org.apache.commons.math4.ga.internal.stats.PopulationStatisticalSummaryImpl;
 import org.apache.commons.math4.ga.listener.ConvergenceListener;
 import org.apache.commons.math4.ga.population.Population;
@@ -40,7 +38,7 @@ import org.jfree.data.xy.XYSeriesCollection;
 /**
  * This class represents the graph plotter during optimization.
  */
-public class GraphPlotter extends JFrame implements ConvergenceListener<List<City>> {
+public class ConvergenceGraphPlotter extends JFrame implements ConvergenceListener<List<City>> {
 
     /**
      * Generated serialversionId.
@@ -56,7 +54,7 @@ public class GraphPlotter extends JFrame implements ConvergenceListener<List<Cit
      * @param xAxisLabel  x axis label
      * @param yAxisLabel  y axis label
      */
-    public GraphPlotter(String plotSubject, String xAxisLabel, String yAxisLabel) {
+    public ConvergenceGraphPlotter(String plotSubject, String xAxisLabel, String yAxisLabel) {
         super(plotSubject);
 
         final JPanel chartPanel = createChartPanel(plotSubject, xAxisLabel, yAxisLabel);
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons/DistanceMatrix.java b/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/DistanceMatrix.java
similarity index 83%
rename from commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons/DistanceMatrix.java
rename to commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/DistanceMatrix.java
index 175c7c6..b6620fa 100644
--- a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/commons/DistanceMatrix.java
+++ b/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/DistanceMatrix.java
@@ -14,25 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.math4.examples.ga.tsp.commons;
+package org.apache.commons.math4.examples.ga.tsp;
 
 import java.util.List;
 
-import org.apache.commons.math4.examples.ga.tsp.utils.Constants;
-
 /**
  * This class represents the distance matrix between cities.
  */
 public final class DistanceMatrix {
 
     /** instance of the class. **/
-    private static final DistanceMatrix INSTANCE = new DistanceMatrix();
+    private static DistanceMatrix instance;
 
     /** distances between cities. **/
     private double[][] distances;
 
-    private DistanceMatrix() {
-        initialize(Constants.CITIES);
+    private DistanceMatrix(List<City> cities) {
+        initialize(cities);
     }
 
     /**
@@ -62,10 +60,14 @@ public final class DistanceMatrix {
 
     /**
      * Returns the instance of this class.
+     * @param cities the cities
      * @return instance
      */
-    public static DistanceMatrix getInstance() {
-        return INSTANCE;
+    public static synchronized DistanceMatrix getInstance(List<City> cities) {
+        if (instance == null) {
+            instance = new DistanceMatrix(cities);
+        }
+        return instance;
     }
 
 }
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/StandAlone.java b/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/StandAlone.java
new file mode 100644
index 0000000..55b5285
--- /dev/null
+++ b/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/StandAlone.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.commons.math4.examples.ga.tsp;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.math4.ga.listener.ConvergenceListenerRegistry;
+import org.apache.commons.math4.ga.listener.PopulationStatisticsLogger;
+
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+@Command(name = "tsp-optimizer", mixinStandardHelpOptions = true, version = "tsp-optimizer 1.0")
+public class StandAlone implements Runnable {
+
+    /** list of cities. **/
+    public static final List<City> CITIES = Collections.unmodifiableList(
+            Arrays.asList(new City[] {new City(1, 0, 0), new City(2, 1, 0), new City(3, 2, 0), new City(4, 3, 0),
+                new City(5, 3, 1), new City(6, 3, 2), new City(7, 3, 3), new City(8, 2, 3), new City(9, 1, 3),
+                new City(10, 0, 3), new City(11, 1, 2), new City(12, 2, 2), new City(13, 2, 1), new City(14, 1, 1)}));
+
+    /** size of tournament. **/
+    @Option(names = "-t", paramLabel = "TOURNAMENT_SIZE", required = true, description = "Tournament size.")
+    private int tournamentSize;
+
+    /** size of population. **/
+    @Option(names = "-p", paramLabel = "POPULATION_SIZE", required = true, description = "Size of population.")
+    private int populationSize;
+
+    /** rate of crossover. **/
+    @Option(names = "-c", paramLabel = "CROSSOVER_RATE", description = "Crossover rate (default: ${DEFAULT-VALUE}).")
+    private double crossoverRate = 1.0;
+
+    /** rate of elitism. **/
+    @Option(names = "-e", paramLabel = "ELITISM_RATE", description = "Elitism rate (default: ${DEFAULT-VALUE}).")
+    private double elitismRate = 0.25;
+
+    /** rate of mutation. **/
+    @Option(names = "-m", paramLabel = "MUTATION_RATE", description = "Mutation rate (default: ${DEFAULT-VALUE}).")
+    private double mutationRate = 0.01;
+
+    /** number of generations with unchanged best fitness. **/
+    @Option(names = "-g", paramLabel = "GENERATIONS_EVOLVED_WITH_UNCHANGED_BEST_FITNESS",
+            description = "No of generations evolved with unchanged best fitness (default: ${DEFAULT-VALUE}).")
+    private int generationsEvolvedWithUnchangedBestFitness = 50;
+
+    public static void main(String[] args) {
+        CommandLine.run(new StandAlone(), args);
+    }
+
+    /**
+     * This method is responsible for validating input and invoking TSP optimizer.
+     */
+    @Override
+    public void run() {
+
+        // validate all input options.
+        validateInput();
+
+        final TSPOptimizer optimizer = new TSPOptimizer();
+
+        final ConvergenceListenerRegistry<List<City>> convergenceListenerRegistry = ConvergenceListenerRegistry
+                .getInstance();
+        convergenceListenerRegistry.addConvergenceListener(new PopulationStatisticsLogger<List<City>>());
+        convergenceListenerRegistry
+                .addConvergenceListener(new ConvergenceGraphPlotter("Convergence Stats", "generation", "fitness"));
+
+        optimizer.optimize(CITIES, crossoverRate, mutationRate, elitismRate, tournamentSize,
+                generationsEvolvedWithUnchangedBestFitness, populationSize);
+
+    }
+
+    private void validateInput() {
+        if (this.tournamentSize < 1) {
+            throw new IllegalArgumentException("Tournament size should be > 0.");
+        }
+        if (populationSize < 2) {
+            throw new IllegalArgumentException("Population size should be > 1.");
+        }
+        if (crossoverRate > 1) {
+            throw new IllegalArgumentException("Crossover rate should be <= 1.");
+        }
+        if (elitismRate >= 1) {
+            throw new IllegalArgumentException("Elitism rate should be < 1.");
+        }
+        if (mutationRate > 1) {
+            throw new IllegalArgumentException("Mutation rate should be <= 1.");
+        }
+        if (generationsEvolvedWithUnchangedBestFitness < 1) {
+            throw new IllegalArgumentException(
+                    "Number of generations evolved with unchanged best fitness should be >= 1.");
+        }
+    }
+}
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/TSPFitnessFunction.java b/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/TSPFitnessFunction.java
index 9b06312..67ab5d7 100644
--- a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/TSPFitnessFunction.java
+++ b/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/TSPFitnessFunction.java
@@ -18,9 +18,6 @@ package org.apache.commons.math4.examples.ga.tsp;
 
 import java.util.List;
 
-
-import org.apache.commons.math4.examples.ga.tsp.commons.City;
-import org.apache.commons.math4.examples.ga.tsp.commons.DistanceMatrix;
 import org.apache.commons.math4.ga.fitness.FitnessFunction;
 
 /**
@@ -33,20 +30,16 @@ public class TSPFitnessFunction implements FitnessFunction<List<City>> {
      */
     @Override
     public double compute(List<City> cities) {
+        final DistanceMatrix distanceMatrix = DistanceMatrix.getInstance(cities);
         double totalDistance = 0.0;
         int index1 = 0;
         int index2 = 0;
         for (int i = 0; i < cities.size(); i++) {
             index1 = i;
             index2 = (i == cities.size() - 1) ? 0 : i + 1;
-            totalDistance += calculateNodeDistance(cities.get(index1), cities.get(index2));
+            totalDistance += distanceMatrix.getDistance(cities.get(index1), cities.get(index2));
         }
         return -totalDistance;
     }
 
-    private double calculateNodeDistance(City node1, City node2) {
-        final DistanceMatrix distanceMatrix = DistanceMatrix.getInstance();
-        return distanceMatrix.getDistance(node1, node2);
-    }
-
 }
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/TSPOptimizer.java b/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/TSPOptimizer.java
index 21833ef..3b209c3 100644
--- a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/TSPOptimizer.java
+++ b/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/TSPOptimizer.java
@@ -18,18 +18,12 @@ package org.apache.commons.math4.examples.ga.tsp;
 
 import java.util.List;
 
-import org.apache.commons.math4.examples.ga.tsp.commons.City;
-import org.apache.commons.math4.examples.ga.tsp.utils.Constants;
-import org.apache.commons.math4.examples.ga.tsp.utils.GraphPlotter;
 import org.apache.commons.math4.ga.GeneticAlgorithm;
 import org.apache.commons.math4.ga.chromosome.RealValuedChromosome;
 import org.apache.commons.math4.ga.convergence.StoppingCondition;
 import org.apache.commons.math4.ga.convergence.UnchangedBestFitness;
 import org.apache.commons.math4.ga.crossover.OnePointCrossover;
 import org.apache.commons.math4.ga.decoder.RandomKeyDecoder;
-import org.apache.commons.math4.ga.internal.exception.GeneticException;
-import org.apache.commons.math4.ga.listener.ConvergenceListenerRegistry;
-import org.apache.commons.math4.ga.listener.PopulationStatisticsLogger;
 import org.apache.commons.math4.ga.mutation.RealValuedMutation;
 import org.apache.commons.math4.ga.population.ListPopulation;
 import org.apache.commons.math4.ga.population.Population;
@@ -41,54 +35,45 @@ import org.slf4j.LoggerFactory;
 /**
  * This class represents the optimizer for traveling salesman problem.
  */
-public class TSPOptimizer {
+public final class TSPOptimizer {
 
-    /** instance of logger. **/
-    private Logger logger = LoggerFactory.getLogger(TSPOptimizer.class);
-
-    /**
-     * Main method to initiate the optimization process.
-     * @param args arguments
-     */
-    public static void main(String[] args) {
-        try {
-            final Population<List<City>> initPopulation = getInitialPopulation(Constants.CITIES);
-
-            final TSPOptimizer optimizer = new TSPOptimizer();
-
-            final ConvergenceListenerRegistry<List<City>> convergenceListenerRegistry = ConvergenceListenerRegistry
-                    .getInstance();
-            convergenceListenerRegistry.addConvergenceListener(new PopulationStatisticsLogger<>());
-            convergenceListenerRegistry
-                    .addConvergenceListener(new GraphPlotter("Convergence", "generation", "total-distance"));
+    /** encoding for console logger. **/
+    public static final String ENCODING = "UTF-8";
 
-            optimizer.optimizeSGA(initPopulation, Constants.CITIES);
-
-            Thread.sleep(5000);
-
-        } catch (InterruptedException e) {
-            throw new GeneticException(e);
-        }
-    }
+    /** instance of logger. **/
+    private final Logger logger = LoggerFactory.getLogger(TSPOptimizer.class);
 
     /**
-     * Optimizes the tsp problem.
-     * @param initial initial population
-     * @param cities  cities
+     * Optimizes the TSP problem.
+     * @param cities                                  list of cities
+     * @param crossoverRate                           rate of crossover
+     * @param mutationRate                            rate of mutation
+     * @param elitismRate                             rate of elitism
+     * @param tournamentSize                          size of tournament
+     * @param generationCountWithUnchangedBestFitness no of generations evolved with
+     *                                                unchanged best fitness
+     * @param populationSize                          size of population
      */
-    public void optimizeSGA(Population<List<City>> initial, List<City> cities) {
+    public void optimize(List<City> cities,
+            double crossoverRate,
+            double mutationRate,
+            double elitismRate,
+            int tournamentSize,
+            int generationCountWithUnchangedBestFitness,
+            int populationSize) {
 
         // initialize a new genetic algorithm
         final GeneticAlgorithm<List<City>> ga = new GeneticAlgorithm<>(new OnePointCrossover<Integer, List<City>>(),
-                Constants.CROSSOVER_RATE, new RealValuedMutation<List<City>>(), Constants.AVERAGE_MUTATION_RATE,
-                new TournamentSelection<List<City>>(Constants.TOURNAMENT_SIZE));
+                crossoverRate, new RealValuedMutation<List<City>>(), mutationRate,
+                new TournamentSelection<List<City>>(tournamentSize), elitismRate);
 
         // stopping condition
         final StoppingCondition<List<City>> stopCond = new UnchangedBestFitness<>(
-                Constants.GENERATION_COUNT_WITH_UNCHANGED_BEST_FUTNESS);
+                generationCountWithUnchangedBestFitness);
 
         // run the algorithm
-        final Population<List<City>> finalPopulation = ga.evolve(initial, stopCond);
+        final Population<List<City>> finalPopulation = ga.evolve(getInitialPopulation(cities, populationSize),
+                stopCond);
 
         // best chromosome from the final population
         final RealValuedChromosome<List<City>> bestFinal = (RealValuedChromosome<List<City>>) finalPopulation
@@ -101,13 +86,13 @@ public class TSPOptimizer {
 
     }
 
-    private static Population<List<City>> getInitialPopulation(List<City> cities) {
-        final Population<List<City>> simulationPopulation = new ListPopulation<>(Constants.POPULATION_SIZE);
+    private static Population<List<City>> getInitialPopulation(List<City> cities, int populationSize) {
+        final Population<List<City>> simulationPopulation = new ListPopulation<>(populationSize);
 
-        for (int i = 0; i < Constants.POPULATION_SIZE; i++) {
-            simulationPopulation.addChromosome(new RealValuedChromosome<>(
-                    ChromosomeRepresentationUtils.randomPermutation(Constants.CHROMOSOME_LENGTH),
-                    new TSPFitnessFunction(), new RandomKeyDecoder<City>(cities)));
+        for (int i = 0; i < populationSize; i++) {
+            simulationPopulation.addChromosome(
+                    new RealValuedChromosome<>(ChromosomeRepresentationUtils.randomPermutation(cities.size()),
+                            new TSPFitnessFunction(), new RandomKeyDecoder<City>(cities)));
         }
 
         return simulationPopulation;
diff --git a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/utils/Constants.java b/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/utils/Constants.java
deleted file mode 100644
index c41cc31..0000000
--- a/commons-math-examples/examples-ga/examples-ga-tsp/src/main/java/org/apache/commons/math4/examples/ga/tsp/utils/Constants.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.commons.math4.examples.ga.tsp.utils;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.commons.math4.examples.ga.tsp.commons.City;
-
-/**
- * This class contains all required constants for this example.
- */
-public final class Constants {
-
-    /** size of population. **/
-    public static final int POPULATION_SIZE = 100;
-
-    /** size of tournament. **/
-    public static final int TOURNAMENT_SIZE = 5;
-
-    /** length of chromosome. **/
-    public static final int CHROMOSOME_LENGTH = 14;
-
-    /** rate of crossover. **/
-    public static final double CROSSOVER_RATE = 1.0;
-
-    /** rate of elitism. **/
-    public static final double ELITISM_RATE = 0.25;
-
-    /** rate of mutation. **/
-    public static final double AVERAGE_MUTATION_RATE = 0.05;
-
-    /** maximum number of generations with unchanged best fitness. **/
-    public static final int GENERATION_COUNT_WITH_UNCHANGED_BEST_FUTNESS = 50;
-
-    /** list of cities. **/
-    public static final List<City> CITIES = Collections.unmodifiableList(
-            Arrays.asList(new City[] {new City(1, 0, 0), new City(2, 1, 0), new City(3, 2, 0), new City(4, 3, 0),
-                new City(5, 3, 1), new City(6, 3, 2), new City(7, 3, 3), new City(8, 2, 3), new City(9, 1, 3),
-                new City(10, 0, 3), new City(11, 1, 2), new City(12, 2, 2), new City(13, 2, 1), new City(14, 1, 1)}));
-
-    /** encoding for console logger. **/
-    public static final String ENCODING = "UTF-8";
-
-    private Constants() {
-
-    }
-
-}
diff --git a/commons-math-examples/examples-ga/pom.xml b/commons-math-examples/examples-ga/pom.xml
index 8432483..dc91479 100644
--- a/commons-math-examples/examples-ga/pom.xml
+++ b/commons-math-examples/examples-ga/pom.xml
@@ -35,22 +35,15 @@
 
     <dependencies>
         <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math-ga</artifactId>
-            <version>4.0-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math3</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.jfree</groupId>
-            <artifactId>jfreechart</artifactId>
-            <version>1.5.3</version>
+            <groupId>info.picocli</groupId>
+            <artifactId>picocli</artifactId>
         </dependency>
     </dependencies>
     <modules>
         <module>examples-ga-math-functions</module>
+        <module>examples-ga-math-functions-adaptive</module>
+        <module>examples-ga-math-functions-legacy</module>
         <module>examples-ga-tsp</module>
+        <module>examples-ga-tsp-legacy</module>
     </modules>
 </project>
\ No newline at end of file
diff --git a/commons-math-examples/examples-ga/src/main/resources/spotbugs/spotbugs-exclude-filter.xml b/commons-math-examples/examples-ga/src/main/resources/spotbugs/spotbugs-exclude-filter.xml
new file mode 100644
index 0000000..8183da2
--- /dev/null
+++ b/commons-math-examples/examples-ga/src/main/resources/spotbugs/spotbugs-exclude-filter.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.
+-->
+
+<!--
+  This file contains some false positive bugs detected by spotbugs. Their
+  false positive nature has been analyzed individually and they have been
+  put here to instruct spotbugs it must ignore them.
+-->
+<FindBugsFilter
+    xmlns="https://github.com/spotbugs/filter/3.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
+
+  <Match>
+    <Class name="~.*\.jmh\..*generated\..*"/>
+  </Match>
+
+  <!-- Deliberately floating-point equality checks. -->
+  <Match>
+    <Class name="org.apache.commons.math4.neuralnet.twod.NeuronSquareMesh2D"/>
+    <Method name="createLinks"/>
+    <BugPattern name="SF_SWITCH_FALLTHROUGH"/>
+  </Match>
+  <Match>
+    <!-- The constant is inlined resulting in a dead-local-store error -->
+    <Class name="org.apache.commons.math4.core.jdkmath.AccurateMath"/>
+    <Method name="atan"/>
+    <BugPattern name="DLS_DEAD_LOCAL_STORE"/>
+  </Match>
+  <Match>
+    <!-- The constant is intentionally close to but not exactly pi/2 -->
+    <Class name="org.apache.commons.math4.core.jdkmath.AccurateMath$CodyWaite"/>
+    <BugPattern name="CNT_ROUGH_CONSTANT_VALUE"/>
+  </Match>
+
+  <!-- Disable checks for exposure of internal references.
+       TODO: Revise this to use more targeted exclusions. -->
+  <Match>
+    <Or>
+      <BugPattern name="EI_EXPOSE_REP"/>
+      <BugPattern name="EI_EXPOSE_REP2"/>
+    </Or>
+  </Match>
+
+  <Match>
+    <!-- ConvergenceListenerRegistry class can expose internal representations -->
+    <Class name="org.apache.commons.math4.ga.listener.ConvergenceListenerRegistry"/>
+    <BugPattern name="MS_EXPOSE_REP"/>
+  </Match>
+
+</FindBugsFilter>
diff --git a/commons-math-examples/examples-sofm/src/main/resources/spotbugs/spotbugs-exclude-filter.xml b/commons-math-examples/examples-sofm/src/main/resources/spotbugs/spotbugs-exclude-filter.xml
new file mode 100644
index 0000000..8183da2
--- /dev/null
+++ b/commons-math-examples/examples-sofm/src/main/resources/spotbugs/spotbugs-exclude-filter.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.
+-->
+
+<!--
+  This file contains some false positive bugs detected by spotbugs. Their
+  false positive nature has been analyzed individually and they have been
+  put here to instruct spotbugs it must ignore them.
+-->
+<FindBugsFilter
+    xmlns="https://github.com/spotbugs/filter/3.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
+
+  <Match>
+    <Class name="~.*\.jmh\..*generated\..*"/>
+  </Match>
+
+  <!-- Deliberately floating-point equality checks. -->
+  <Match>
+    <Class name="org.apache.commons.math4.neuralnet.twod.NeuronSquareMesh2D"/>
+    <Method name="createLinks"/>
+    <BugPattern name="SF_SWITCH_FALLTHROUGH"/>
+  </Match>
+  <Match>
+    <!-- The constant is inlined resulting in a dead-local-store error -->
+    <Class name="org.apache.commons.math4.core.jdkmath.AccurateMath"/>
+    <Method name="atan"/>
+    <BugPattern name="DLS_DEAD_LOCAL_STORE"/>
+  </Match>
+  <Match>
+    <!-- The constant is intentionally close to but not exactly pi/2 -->
+    <Class name="org.apache.commons.math4.core.jdkmath.AccurateMath$CodyWaite"/>
+    <BugPattern name="CNT_ROUGH_CONSTANT_VALUE"/>
+  </Match>
+
+  <!-- Disable checks for exposure of internal references.
+       TODO: Revise this to use more targeted exclusions. -->
+  <Match>
+    <Or>
+      <BugPattern name="EI_EXPOSE_REP"/>
+      <BugPattern name="EI_EXPOSE_REP2"/>
+    </Or>
+  </Match>
+
+  <Match>
+    <!-- ConvergenceListenerRegistry class can expose internal representations -->
+    <Class name="org.apache.commons.math4.ga.listener.ConvergenceListenerRegistry"/>
+    <BugPattern name="MS_EXPOSE_REP"/>
+  </Match>
+
+</FindBugsFilter>
diff --git a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/AdaptiveGeneticAlgorithm.java b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/AdaptiveGeneticAlgorithm.java
index 07e8913..bf1c800 100644
--- a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/AdaptiveGeneticAlgorithm.java
+++ b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/AdaptiveGeneticAlgorithm.java
@@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
 public class AdaptiveGeneticAlgorithm<P> extends AbstractGeneticAlgorithm<P> {
 
     /** instance of logger. **/
-    private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGeneticAlgorithm.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(AdaptiveGeneticAlgorithm.class);
 
     /** The crossover rate generator. **/
     private final CrossoverRateGenerator<P> crossoverRateGenerator;
diff --git a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/GeneticAlgorithm.java b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/GeneticAlgorithm.java
index 94e320d..0a8cc77 100644
--- a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/GeneticAlgorithm.java
+++ b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/GeneticAlgorithm.java
@@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
 public class GeneticAlgorithm<P> extends AbstractGeneticAlgorithm<P> {
 
     /** instance of logger. **/
-    private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGeneticAlgorithm.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(GeneticAlgorithm.class);
 
     /** crossover rate string. **/
     private static final String CROSSOVER_RATE = "CROSSOVER_RATE";
diff --git a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/chromosome/BinaryChromosome.java b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/chromosome/BinaryChromosome.java
index a9ef839..13e0bf1 100644
--- a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/chromosome/BinaryChromosome.java
+++ b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/chromosome/BinaryChromosome.java
@@ -17,7 +17,6 @@
 package org.apache.commons.math4.ga.chromosome;
 
 import java.util.List;
-
 import java.util.Objects;
 
 import org.apache.commons.math4.ga.decoder.Decoder;
@@ -125,7 +124,7 @@ public class BinaryChromosome<P> extends AbstractChromosome<P> {
      * Checks the input chromosome length against predefined maximum length.
      * @param chromosomeLength input chromsome length
      */
-    protected void checkMaximumLength(long chromosomeLength) {
+    private void checkMaximumLength(long chromosomeLength) {
         if (chromosomeLength > MAX_LENGTH) {
             throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT,
                     "length exceeded the max length " + MAX_LENGTH);
@@ -206,8 +205,9 @@ public class BinaryChromosome<P> extends AbstractChromosome<P> {
             throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT,
                     "start " + start + " is greater than end " + end);
         }
-        if (end - start > Integer.MAX_VALUE) {
-            throw new GeneticException(GeneticException.LENGTH_TOO_LARGE, end - start);
+        if (end > length) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT,
+                    "end " + end + " is greater than length " + length);
         }
         final int offset = (int) (length % Long.SIZE == 0 ? 0 : Long.SIZE - length % Long.SIZE);
         final long offsettedStart = offset + start;
@@ -250,7 +250,7 @@ public class BinaryChromosome<P> extends AbstractChromosome<P> {
      */
     private String getAlleleBlockString(final int alleleBlockIndex) {
         return prepareZeroPrefix(representation[alleleBlockIndex] == 0 ? Long.SIZE - 1 :
-                Long.numberOfLeadingZeros(representation[alleleBlockIndex])) +
+            Long.numberOfLeadingZeros(representation[alleleBlockIndex])) +
                 Long.toUnsignedString(representation[alleleBlockIndex], 2);
     }
 
diff --git a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/AbstractListChromosomeCrossoverPolicy.java b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/AbstractListChromosomeCrossoverPolicy.java
index 2184310..8b773a5 100644
--- a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/AbstractListChromosomeCrossoverPolicy.java
+++ b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/AbstractListChromosomeCrossoverPolicy.java
@@ -51,7 +51,7 @@ public abstract class AbstractListChromosomeCrossoverPolicy<T, P> extends Abstra
      * @param second second chromosome
      */
     @SuppressWarnings("unchecked")
-    protected void checkValidity(final Chromosome<P> first, final Chromosome<P> second) {
+    private void checkValidity(final Chromosome<P> first, final Chromosome<P> second) {
         if (!(first instanceof AbstractListChromosome<?, ?> && second instanceof AbstractListChromosome<?, ?>)) {
             throw new GeneticException(GeneticException.INVALID_FIXED_LENGTH_CHROMOSOME);
         }
diff --git a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/CycleCrossover.java b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/CycleCrossover.java
index 1d0da03..ff4bf34 100644
--- a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/CycleCrossover.java
+++ b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/CycleCrossover.java
@@ -17,7 +17,6 @@
 package org.apache.commons.math4.ga.crossover;
 
 import java.util.ArrayList;
-
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -46,6 +45,7 @@ import org.apache.commons.math4.ga.utils.RandomProviderManager;
  * ...
  *
  * Example (zero-start cycle):
+ *
  * <pre>
  * p1 = (8 4 7 3 6 2 5 1 9 0)    X   c1 = (8 1 2 3 4 5 6 7 9 0)
  * p2 = (0 1 2 3 4 5 6 7 8 9)    X   c2 = (0 4 7 3 6 2 5 1 8 9)
diff --git a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/OrderedCrossover.java b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/OrderedCrossover.java
index 24608f9..c53180f 100644
--- a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/OrderedCrossover.java
+++ b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/OrderedCrossover.java
@@ -17,7 +17,6 @@
 package org.apache.commons.math4.ga.crossover;
 
 import java.util.ArrayList;
-
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
diff --git a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/UniformCrossover.java b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/UniformCrossover.java
index 23292f7..df5321a 100644
--- a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/UniformCrossover.java
+++ b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/crossover/UniformCrossover.java
@@ -17,7 +17,6 @@
 package org.apache.commons.math4.ga.crossover;
 
 import java.util.ArrayList;
-
 import java.util.List;
 
 import org.apache.commons.math4.ga.chromosome.AbstractListChromosome;
diff --git a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/decoder/AbstractListChromosomeDecoder.java b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/decoder/AbstractListChromosomeDecoder.java
index 96a1920..fccc851 100644
--- a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/decoder/AbstractListChromosomeDecoder.java
+++ b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/decoder/AbstractListChromosomeDecoder.java
@@ -34,6 +34,7 @@ public abstract class AbstractListChromosomeDecoder<T, P> implements Decoder<P>
     @SuppressWarnings("unchecked")
     @Override
     public P decode(Chromosome<P> chromosome) {
+        //check for validity
         checkValidity(chromosome);
 
         return decode((AbstractListChromosome<T, P>) chromosome);
@@ -43,7 +44,7 @@ public abstract class AbstractListChromosomeDecoder<T, P> implements Decoder<P>
      * Checks validity of {@link Chromosome}.
      * @param chromosome the {@link Chromosome}
      */
-    protected void checkValidity(Chromosome<P> chromosome) {
+    private void checkValidity(Chromosome<P> chromosome) {
         if (!AbstractListChromosome.class.isAssignableFrom(chromosome.getClass())) {
             throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, chromosome.getClass().getSimpleName());
         }
diff --git a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/AbstractListChromosomeMutationPolicy.java b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/AbstractListChromosomeMutationPolicy.java
index 3e41fc2..f2ace6a 100644
--- a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/AbstractListChromosomeMutationPolicy.java
+++ b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/AbstractListChromosomeMutationPolicy.java
@@ -24,6 +24,7 @@ import java.util.Set;
 
 import org.apache.commons.math4.ga.chromosome.AbstractListChromosome;
 import org.apache.commons.math4.ga.chromosome.Chromosome;
+import org.apache.commons.math4.ga.internal.exception.GeneticException;
 import org.apache.commons.math4.ga.utils.RandomProviderManager;
 import org.apache.commons.rng.UniformRandomProvider;
 
@@ -43,8 +44,9 @@ public abstract class AbstractListChromosomeMutationPolicy<T, P> implements Muta
      * @return the mutated chromosome.
      */
     @Override
-    public Chromosome<P> mutate(Chromosome<P> original, double mutationRate) {
-        // check for validity.
+    public AbstractListChromosome<T, P> mutate(Chromosome<P> original, double mutationRate) {
+
+        // check for validity
         checkValidity(original);
 
         @SuppressWarnings("unchecked")
@@ -60,10 +62,14 @@ public abstract class AbstractListChromosomeMutationPolicy<T, P> implements Muta
     }
 
     /**
-     * Checks input chromosome validity.
-     * @param original chromosome to be mutated
+     * This method validates input chromosome.
+     * @param original chromosome
      */
-    protected abstract void checkValidity(Chromosome<P> original);
+    private void checkValidity(Chromosome<P> original) {
+        if (!AbstractListChromosome.class.isAssignableFrom(original.getClass())) {
+            throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, original.getClass().getSimpleName());
+        }
+    }
 
     /**
      * Selects and returns mutable gene indexes based on mutation rate.
@@ -71,7 +77,7 @@ public abstract class AbstractListChromosomeMutationPolicy<T, P> implements Muta
      * @param mutationRate mutation rate of the allele/gene
      * @return mutable gene indexes
      */
-    protected Set<Integer> getMutableGeneIndexes(int length, double mutationRate) {
+    private Set<Integer> getMutableGeneIndexes(int length, double mutationRate) {
 
         // calculate the total mutation rate of all the alleles i.e. chromosome.
         final double chromosomeMutationRate = mutationRate * length;
diff --git a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/BinaryMutation.java b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/BinaryMutation.java
index 2470f38..d6c3e0e 100644
--- a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/BinaryMutation.java
+++ b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/BinaryMutation.java
@@ -38,7 +38,7 @@ public class BinaryMutation<P> implements MutationPolicy<P> {
      * {@inheritDoc}
      */
     @Override
-    public Chromosome<P> mutate(Chromosome<P> original, double mutationRate) {
+    public BinaryChromosome<P> mutate(Chromosome<P> original, double mutationRate) {
         // check for validity.
         checkValidity(original);
         final BinaryChromosome<P> chromosome = (BinaryChromosome<P>) original;
@@ -57,14 +57,6 @@ public class BinaryMutation<P> implements MutationPolicy<P> {
             }
             newRep[alleleBlockIndex] = newRep[alleleBlockIndex] ^ mask;
         }
-//        for (int alleleBlockIndex : mutableGeneIndexMap.keySet()) {
-//            long mask = 0;
-//            final Set<Integer> alleleElementIndexes = mutableGeneIndexMap.get(alleleBlockIndex);
-//            for (int index : alleleElementIndexes) {
-//                mask += index == 0 ? Long.MIN_VALUE : Math.pow(2, Long.SIZE - 1 - index);
-//            }
-//            newRep[alleleBlockIndex] = newRep[alleleBlockIndex] ^ mask;
-//        }
 
         return chromosome.newChromosome(newRep, chromosome.getLength());
     }
@@ -73,7 +65,7 @@ public class BinaryMutation<P> implements MutationPolicy<P> {
      * Checks input chromosome validity.
      * @param original chromosome to be mutated
      */
-    protected void checkValidity(Chromosome<P> original) {
+    private void checkValidity(Chromosome<P> original) {
         if (!BinaryChromosome.class.isAssignableFrom(original.getClass())) {
             throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, original.getClass().getSimpleName());
         }
@@ -85,7 +77,7 @@ public class BinaryMutation<P> implements MutationPolicy<P> {
      * @param mutationRate mutation rate of the allele/gene
      * @return mutable gene indexes
      */
-    protected Map<Integer, Set<Integer>> getMutableGeneIndexes(long length, double mutationRate) {
+    private Map<Integer, Set<Integer>> getMutableGeneIndexes(long length, double mutationRate) {
 
         // calculate the total mutation rate of all the alleles i.e. chromosome.
         final double chromosomeMutationRate = mutationRate * length;
diff --git a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/IntegralValuedMutation.java b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/IntegralValuedMutation.java
index 2ff7f0f..64fe6cf 100644
--- a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/IntegralValuedMutation.java
+++ b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/IntegralValuedMutation.java
@@ -36,14 +36,19 @@ public class IntegralValuedMutation<P> extends AbstractListChromosomeMutationPol
 
     /**
      * @param min minimum value of allele
-     * @param max maximum value of allele
+     * @param max maximum(exclusive) value of allele
      */
     public IntegralValuedMutation(final int min, final int max) {
         this.min = min;
         this.max = max;
-        if (min >= max) {
+
+        // To perform mutation for an IntegralValuedChromosome the minimum difference
+        // between
+        // max and min should be 2.
+        if ((max - min) < 2) {
             throw new GeneticException(GeneticException.TOO_LARGE, min, max);
         }
+
     }
 
     /**
@@ -66,7 +71,18 @@ public class IntegralValuedMutation<P> extends AbstractListChromosomeMutationPol
      * {@inheritDoc}
      */
     @Override
-    protected void checkValidity(Chromosome<P> original) {
+    public IntegralValuedChromosome<P> mutate(Chromosome<P> original, double mutationRate) {
+        // check for validity
+        checkValidity(original);
+
+        return (IntegralValuedChromosome<P>) super.mutate(original, mutationRate);
+    }
+
+    /**
+     * This method validates input chromosome.
+     * @param original chromosome
+     */
+    private void checkValidity(Chromosome<P> original) {
         if (!IntegralValuedChromosome.class.isAssignableFrom(original.getClass())) {
             throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, original.getClass().getSimpleName());
         }
@@ -82,7 +98,12 @@ public class IntegralValuedMutation<P> extends AbstractListChromosomeMutationPol
      */
     @Override
     protected Integer mutateGene(Integer originalValue) {
-        return min + RandomProviderManager.getRandomProvider().nextInt(max - min);
+        Integer mutatedValue = 0;
+        do {
+            mutatedValue = min + RandomProviderManager.getRandomProvider().nextInt(max - min);
+        } while (mutatedValue.equals(originalValue));
+
+        return mutatedValue;
     }
 
 }
diff --git a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/RealValuedMutation.java b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/RealValuedMutation.java
index 3dcbdcf..d5ea01f 100644
--- a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/RealValuedMutation.java
+++ b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/mutation/RealValuedMutation.java
@@ -75,7 +75,17 @@ public class RealValuedMutation<P> extends AbstractListChromosomeMutationPolicy<
      * {@inheritDoc}
      */
     @Override
-    protected void checkValidity(Chromosome<P> original) {
+    public RealValuedChromosome<P> mutate(Chromosome<P> original, double mutationRate) {
+        // check for validity.
+        checkValidity(original);
+        return (RealValuedChromosome<P>) super.mutate(original, mutationRate);
+    }
+
+    /**
+     * This method validates the input chromosome.
+     * @param original chromosome
+     */
+    private void checkValidity(Chromosome<P> original) {
         if (!RealValuedChromosome.class.isAssignableFrom(original.getClass())) {
             throw new GeneticException(GeneticException.ILLEGAL_ARGUMENT, original.getClass().getSimpleName());
         }
@@ -91,7 +101,12 @@ public class RealValuedMutation<P> extends AbstractListChromosomeMutationPolicy<
      */
     @Override
     protected Double mutateGene(Double originalValue) {
-        return min + RandomProviderManager.getRandomProvider().nextDouble() * (max - min);
+        Double mutatedValue = 0.0;
+        do {
+            mutatedValue = min + RandomProviderManager.getRandomProvider().nextDouble() * (max - min);
+        } while (mutatedValue.equals(originalValue));
+
+        return mutatedValue;
     }
 
 }
diff --git a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/population/ListPopulation.java b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/population/ListPopulation.java
index 1622d9c..405edcc 100644
--- a/commons-math-ga/src/main/java/org/apache/commons/math4/ga/population/ListPopulation.java
+++ b/commons-math-ga/src/main/java/org/apache/commons/math4/ga/population/ListPopulation.java
@@ -99,15 +99,6 @@ public class ListPopulation<P> implements Population<P> {
     }
 
     /**
-     * Access the list of chromosomes.
-     * @return the list of chromosomes
-     * @since 3.1
-     */
-    protected List<Chromosome<P>> getChromosomeList() {
-        return chromosomes;
-    }
-
-    /**
      * Add the given chromosome to the population.
      * @param chromosome the chromosome to add.
      */
@@ -195,7 +186,7 @@ public class ListPopulation<P> implements Population<P> {
      */
     @Override
     public Population<P> nextGeneration(final double elitismRate) {
-        final List<Chromosome<P>> oldChromosomes = getChromosomeList();
+        final List<Chromosome<P>> oldChromosomes = this.chromosomes;
 
         if ((int) (oldChromosomes.size() * elitismRate) == 0) {
             // if no of elite chromosome is 0 crete and return an empty population instance.
diff --git a/commons-math-ga/src/test/java/org/apache/commons/math4/ga/chromosome/BinaryChromosomeTest.java b/commons-math-ga/src/test/java/org/apache/commons/math4/ga/chromosome/BinaryChromosomeTest.java
index ef6669a..a092ae9 100644
--- a/commons-math-ga/src/test/java/org/apache/commons/math4/ga/chromosome/BinaryChromosomeTest.java
+++ b/commons-math-ga/src/test/java/org/apache/commons/math4/ga/chromosome/BinaryChromosomeTest.java
@@ -19,6 +19,7 @@ package org.apache.commons.math4.ga.chromosome;
 import org.apache.commons.math4.ga.dummy.DummyListChromosomeDecoder;
 import org.apache.commons.math4.ga.internal.exception.GeneticException;
 import org.apache.commons.math4.ga.utils.ChromosomeRepresentationUtils;
+import org.junit.Assert;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
@@ -89,4 +90,12 @@ public class BinaryChromosomeTest {
         }
     }
 
+    @Test
+    public void testStringRepresentationWithRange() {
+        int length = 100;
+        String representationStr = ChromosomeRepresentationUtils.randomStringRepresentation(new char[] {'0', '1'},
+                length);
+        BinaryChromosome<String> chromosome = new BinaryChromosome<>(representationStr, c -> 0, c -> "0");
+        Assert.assertThrows(GeneticException.class, () -> chromosome.getStringRepresentation(10, length + 1));
+    }
 }
diff --git a/commons-math-ga/src/test/java/org/apache/commons/math4/ga/dummy/DummyListChromosomeDecoder.java b/commons-math-ga/src/test/java/org/apache/commons/math4/ga/dummy/DummyListChromosomeDecoder.java
index 541cd26..969e69c 100644
--- a/commons-math-ga/src/test/java/org/apache/commons/math4/ga/dummy/DummyListChromosomeDecoder.java
+++ b/commons-math-ga/src/test/java/org/apache/commons/math4/ga/dummy/DummyListChromosomeDecoder.java
@@ -17,7 +17,6 @@
 package org.apache.commons.math4.ga.dummy;
 
 import org.apache.commons.math4.ga.chromosome.AbstractListChromosome;
-import org.apache.commons.math4.ga.chromosome.Chromosome;
 import org.apache.commons.math4.ga.decoder.AbstractListChromosomeDecoder;
 
 public class DummyListChromosomeDecoder<T> extends AbstractListChromosomeDecoder<T, String> {
@@ -33,9 +32,4 @@ public class DummyListChromosomeDecoder<T> extends AbstractListChromosomeDecoder
         return value;
     }
 
-    @Override
-    protected void checkValidity(Chromosome<String> chromosome) {
-        // No op
-    }
-
 }
diff --git a/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/AbstractListChromosomeMutationPolicyTest.java b/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/AbstractListChromosomeMutationPolicyTest.java
deleted file mode 100644
index 17c481a..0000000
--- a/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/AbstractListChromosomeMutationPolicyTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-package org.apache.commons.math4.ga.mutation;
-
-import org.apache.commons.math4.ga.chromosome.Chromosome;
-import org.apache.commons.math4.ga.utils.RandomProviderManager;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class AbstractListChromosomeMutationPolicyTest {
-
-    @Test
-    public void testGetMutableGeneIndexes() {
-        AbstractListChromosomeMutationPolicy<Integer, String> chromosomeMutationPolicy = new AbstractListChromosomeMutationPolicy<Integer, String>() {
-
-            @Override
-            protected Integer mutateGene(Integer originalValue) {
-                return RandomProviderManager.getRandomProvider().nextInt(2);
-            }
-
-            @Override
-            protected void checkValidity(Chromosome<String> original) {
-                // No Op
-            }
-        };
-        Assertions.assertEquals(1, chromosomeMutationPolicy.getMutableGeneIndexes(10, .1).size());
-        chromosomeMutationPolicy.getMutableGeneIndexes(10, .001);
-    }
-
-}
diff --git a/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/BinaryMutationTest.java b/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/BinaryMutationTest.java
index d2cc2bb..5cc7127 100644
--- a/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/BinaryMutationTest.java
+++ b/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/BinaryMutationTest.java
@@ -30,9 +30,9 @@ public class BinaryMutationTest {
     public void testCheckValidity() {
         BinaryMutation<String> mutation = new BinaryMutation<>();
         Assertions.assertThrows(GeneticException.class, () -> {
-            mutation.checkValidity(new IntegralValuedChromosome<String>(
+            mutation.mutate(new IntegralValuedChromosome<String>(
                     ChromosomeRepresentationUtils.randomIntegralRepresentation(10, 0, 2), c -> 0,
-                    new DummyListChromosomeDecoder<>("0"), 0, 2));
+                    new DummyListChromosomeDecoder<>("0"), 0, 2), .1);
         });
     }
 
diff --git a/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/IntegralValuedMutationTest.java b/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/IntegralValuedMutationTest.java
index 0d6135f..19f4f36 100644
--- a/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/IntegralValuedMutationTest.java
+++ b/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/IntegralValuedMutationTest.java
@@ -37,7 +37,7 @@ public class IntegralValuedMutationTest {
                 new DummyListChromosomeDecoder<>("0"));
         IntegralValuedMutation<String> mutation = new IntegralValuedMutation<>(min - 10, max);
         Assertions.assertThrows(GeneticException.class, () -> {
-            mutation.checkValidity(chromosome);
+            mutation.mutate(chromosome, .1);
         });
     }
 
@@ -50,7 +50,7 @@ public class IntegralValuedMutationTest {
                 new DummyListChromosomeDecoder<>("0"), min, max);
         IntegralValuedMutation<String> mutation = new IntegralValuedMutation<>(min - 10, max);
         Assertions.assertThrows(GeneticException.class, () -> {
-            mutation.checkValidity(chromosome);
+            mutation.mutate(chromosome, .1);
         });
     }
 
@@ -79,6 +79,7 @@ public class IntegralValuedMutationTest {
             int origValue = min + RandomProviderManager.getRandomProvider().nextInt(max - min);
             int mutatedValued = mutation.mutateGene(origValue);
             Assertions.assertTrue(min <= mutatedValued && mutatedValued < max);
+            Assertions.assertNotEquals(origValue, mutatedValued);
         }
     }
 
diff --git a/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/RealValuedMutationTest.java b/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/RealValuedMutationTest.java
index 015801b..c3ee9ff 100644
--- a/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/RealValuedMutationTest.java
+++ b/commons-math-ga/src/test/java/org/apache/commons/math4/ga/mutation/RealValuedMutationTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.math4.ga.mutation;
 
+import java.util.List;
+
 import org.apache.commons.math4.ga.chromosome.Chromosome;
 import org.apache.commons.math4.ga.chromosome.IntegralValuedChromosome;
 import org.apache.commons.math4.ga.chromosome.RealValuedChromosome;
@@ -37,7 +39,7 @@ public class RealValuedMutationTest {
                 new DummyListChromosomeDecoder<>("0"), min, max);
         RealValuedMutation<String> mutation = new RealValuedMutation<>(min - 10, max);
         Assertions.assertThrows(GeneticException.class, () -> {
-            mutation.checkValidity(chromosome);
+            mutation.mutate(chromosome, .1);
         });
     }
 
@@ -50,12 +52,34 @@ public class RealValuedMutationTest {
                 new DummyListChromosomeDecoder<>("0"), min, max);
         RealValuedMutation<String> mutation = new RealValuedMutation<>(min - 10, max);
         Assertions.assertThrows(GeneticException.class, () -> {
-            mutation.checkValidity(chromosome);
+            mutation.mutate(chromosome, .1);
         });
     }
 
     @Test
-    public void testIntegralValuedMutation() {
+    public void testGetMutableGeneIndexes() {
+        RealValuedMutation<String> mutationPolicy = new RealValuedMutation<>(0, 10);
+        List<Double> representation = ChromosomeRepresentationUtils.randomDoubleRepresentation(10, 0, 10);
+        RealValuedChromosome<String> chromosome = new RealValuedChromosome<>(representation, c -> 0,
+                new DummyListChromosomeDecoder<>("0"), 0, 10);
+        RealValuedChromosome<String> mutatedChromosome = mutationPolicy.mutate(chromosome, .2);
+        Assertions.assertEquals(2, calculatedMutatedAlleleCount(representation, mutatedChromosome.getRepresentation()));
+        mutatedChromosome = mutationPolicy.mutate(chromosome, .1);
+        Assertions.assertEquals(1, calculatedMutatedAlleleCount(representation, mutatedChromosome.getRepresentation()));
+    }
+
+    private int calculatedMutatedAlleleCount(List<Double> representation, List<Double> mutatedRepresentation) {
+        int mutationCount = 0;
+        for (int i = 0; i < representation.size(); i++) {
+            if (representation.get(i) != mutatedRepresentation.get(i)) {
+                mutationCount++;
+            }
+        }
+        return mutationCount;
+    }
+
+    @Test
+    public void testRealValuedMutation() {
         Assertions.assertThrows(GeneticException.class, () -> {
             new RealValuedMutation<>(10, 5);
         });
@@ -79,6 +103,7 @@ public class RealValuedMutationTest {
             double origValue = min + (max - min) * RandomProviderManager.getRandomProvider().nextDouble();
             double mutatedValue = mutation.mutateGene(origValue);
             Assertions.assertTrue(min <= mutatedValue && mutatedValue < max);
+            Assertions.assertNotEquals(origValue, mutatedValue);
         }
     }
 
diff --git a/pom.xml b/pom.xml
index 1fef467..763e987 100644
--- a/pom.xml
+++ b/pom.xml
@@ -127,7 +127,6 @@
 
     <!-- 4. Modules that depend on "legacy" codes. -->
     <module>commons-math-examples</module>
-
   </modules>
 
   <scm>
diff --git a/src/main/resources/checkstyle/checkstyle-suppressions.xml b/src/main/resources/checkstyle/checkstyle-suppressions.xml
index 1e58559..75d9f39 100644
--- a/src/main/resources/checkstyle/checkstyle-suppressions.xml
+++ b/src/main/resources/checkstyle/checkstyle-suppressions.xml
@@ -35,6 +35,7 @@
   <suppress checks="ParameterNumber" files=".*[/\\]Dfp\.java" />
   <suppress checks="TypeName" files=".*[/\\]AccurateMath\.java" />
   <suppress checks="ParameterName" files=".*[/\\]AccurateMathCalc\.java" />
+  <suppress checks="ParameterNumber" files=".*[/\\]AdaptiveMathFunctionOptimizer\.java"/>
 
   <!-- Be more lenient on tests. -->
   <suppress checks="Javadoc" files=".*[/\\]test[/\\].*" />