diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 083c9fb5bc10101fe6b14a3bd635439cd385b95a..0fe8b32301b9ddba785de007963580763ea46ea4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,9 @@ cache: - paths: - - .m2/ + paths: + - .m2/ variables: - MAVEN_OPTS: "-Dmaven.repo.local=.m2" + MAVEN_OPTS: "-Dmaven.repo.local=.m2" image: maven:3.5.3-jdk-8 diff --git a/checkstyle.xml b/checkstyle.xml index bb821bb45c2e13b26c128eef1895dcd82a80417d..77b8d988c2662d4d3559e372a2b464be7c77fa34 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -1,7 +1,7 @@ <?xml version="1.0"?> <!DOCTYPE module PUBLIC - "-//Puppy Crawl//DTD Check Configuration 1.2//EN" - "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> + "-//Puppy Crawl//DTD Check Configuration 1.2//EN" + "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> <!-- Checkstyle configuration based on sun_checks.xml with: @@ -82,13 +82,13 @@ <!-- Checks for Javadoc comments. --> <!-- See http://checkstyle.sf.net/config_javadoc.html --> <module name="JavadocMethod"> - <property name="scope" value="public"/> - <property name="allowMissingReturnTag" value="true" /> - <property name="allowMissingParamTags" value="true" /> + <property name="scope" value="public"/> + <property name="allowMissingReturnTag" value="true"/> + <property name="allowMissingParamTags" value="true"/> </module> <module name="JavadocType"/> <module name="JavadocVariable"> - <property name="scope" value="public"/> + <property name="scope" value="public"/> </module> <module name="JavadocStyle"/> @@ -96,33 +96,33 @@ <!-- Checks for Naming Conventions. --> <!-- See http://checkstyle.sf.net/config_naming.html --> <module name="ConstantName"/> - + <module name="LocalFinalVariableName"> <property name="format" value="^[a-z][a-z0-9\_]*$"/> </module> - + <module name="LocalVariableName"> - <property name="format" value="^[a-z][a-z0-9\_]*$"/> - <property name="allowOneCharVarInForLoop" value="true"/> + <property name="format" value="^[a-z][a-z0-9\_]*$"/> + <property name="allowOneCharVarInForLoop" value="true"/> </module> - + <module name="MemberName"> - <property name="format" value="^[a-z][a-z0-9\_]*$"/> + <property name="format" value="^[a-z][a-z0-9\_]*$"/> </module> - + <module name="ParameterName"> - <property name="format" value="^[a-z][a-z0-9\_]*$"/> + <property name="format" value="^[a-z][a-z0-9\_]*$"/> </module> - + <!--<module name="CatchParameterName"> <property name="format" value="^[a-z][a-z0-9\_]+$"/> </module>--> - + <module name="StaticVariableName"> - <property name="format" value="^[a-z][a-z0-9\_]*$"/> + <property name="format" value="^[a-z][a-z0-9\_]*$"/> </module> - - + + <module name="MethodName"/> <module name="PackageName"/> <module name="TypeName"/> @@ -131,15 +131,15 @@ <!-- Checks for Headers --> <!-- See http://checkstyle.sf.net/config_header.html --> <!-- <module name="Header"> --> - <!-- The follow property value demonstrates the ability --> - <!-- to have access to ANT properties. In this case it uses --> - <!-- the ${basedir} property to allow Checkstyle to be run --> - <!-- from any directory within a project. See property --> - <!-- expansion, --> - <!-- http://checkstyle.sf.net/config.html#properties --> - <!-- <property --> - <!-- name="headerFile" --> - <!-- value="${basedir}/java.header"/> --> + <!-- The follow property value demonstrates the ability --> + <!-- to have access to ANT properties. In this case it uses --> + <!-- the ${basedir} property to allow Checkstyle to be run --> + <!-- from any directory within a project. See property --> + <!-- expansion, --> + <!-- http://checkstyle.sf.net/config.html#properties --> + <!-- <property --> + <!-- name="headerFile" --> + <!-- value="${basedir}/java.header"/> --> <!-- </module> --> diff --git a/pom.xml b/pom.xml index 43a24ff81da988bdea5827cca08270c8d5a0764f..5462abc9c01630f6f4b838e58aaca867f2eee54a 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>be.cylab</groupId> <artifactId>java-wowa-training</artifactId> diff --git a/src/main/java/be/cylab/java/wowa/training/Example.java b/src/main/java/be/cylab/java/wowa/training/Example.java index d71b11dec02eb78f695b40c6597d5271386f4f57..87e8da29fad95a228cc11672efb992e1d06c9e5b 100644 --- a/src/main/java/be/cylab/java/wowa/training/Example.java +++ b/src/main/java/be/cylab/java/wowa/training/Example.java @@ -1,22 +1,19 @@ - package be.cylab.java.wowa.training; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.logging.Logger; /** - * * @author tibo */ public class Example { - public static void main(String [] args) { + public static void main(String[] args) { TrainerParameters parameters = new TrainerParameters(10, 10, 10, TrainerParameters.SELECTION_METHOD_RWS, 25); Trainer trainer = new Trainer(parameters); List<double[]> data = new ArrayList<>(); - for (int i = 0;i < 5; i++) { + for (int i = 0; i < 5; i++) { double[] element = {Math.random(), Math.random(), Math.random()}; data.add(element); } @@ -30,7 +27,7 @@ public class Example { for (SolutionDistance solution : population) { System.out.println(solution); } - System.out.println("Trié\n"); + System.out.println("Trié\n"); Collections.sort(population); for (SolutionDistance solution : population) { System.out.println(solution); diff --git a/src/main/java/be/cylab/java/wowa/training/SolutionDistance.java b/src/main/java/be/cylab/java/wowa/training/SolutionDistance.java index c447018148f0fd3f0ed63b0e9a3c16d9a726082a..bfc789973f9c89d926cfaa011280ec52ab8a8a1c 100644 --- a/src/main/java/be/cylab/java/wowa/training/SolutionDistance.java +++ b/src/main/java/be/cylab/java/wowa/training/SolutionDistance.java @@ -18,7 +18,6 @@ public class SolutionDistance implements Comparable<SolutionDistance> { } /** - * * @return */ @Override @@ -31,7 +30,6 @@ public class SolutionDistance implements Comparable<SolutionDistance> { } /** - * * @param data * @param expected */ @@ -42,7 +40,6 @@ public class SolutionDistance implements Comparable<SolutionDistance> { } /** - * * @param probability */ public void randomlyMutateWithProbability(final double probability) { @@ -67,7 +64,6 @@ public class SolutionDistance implements Comparable<SolutionDistance> { } /** - * * @param solution * @return */ @@ -85,7 +81,6 @@ public class SolutionDistance implements Comparable<SolutionDistance> { } /** - * * @return */ public double getDistance() { diff --git a/src/main/java/be/cylab/java/wowa/training/Trainer.java b/src/main/java/be/cylab/java/wowa/training/Trainer.java index 8af89449459de21c6beb5d1da52fd3dd4f0f49a6..d120aedfaffea3558a6eb1cbc1aabce6743c63f6 100644 --- a/src/main/java/be/cylab/java/wowa/training/Trainer.java +++ b/src/main/java/be/cylab/java/wowa/training/Trainer.java @@ -14,7 +14,6 @@ public class Trainer { } /** - * * @param data * @param expected * @return @@ -45,7 +44,6 @@ public class Trainer { } /** - * * @param solutions * @return */ @@ -61,7 +59,6 @@ public class Trainer { } /** - * * @param numberOfWeights * @param populationSize * @return @@ -81,7 +78,6 @@ public class Trainer { } /** - * * @param solutions * @param data * @param expected @@ -96,7 +92,6 @@ public class Trainer { } /** - * * @param solutions * @param selected_elements * @param count @@ -127,7 +122,6 @@ public class Trainer { } /** - * * @param solutions * @param selected_elements * @param count @@ -160,7 +154,6 @@ public class Trainer { } /** - * * @param solutions * @param count * @param selectionMethod @@ -190,7 +183,6 @@ public class Trainer { } /** - * * @param solutions * @return */ @@ -218,7 +210,6 @@ public class Trainer { } /** - * * @param dad * @param mom * @param solutions @@ -267,7 +258,6 @@ public class Trainer { } /** - * * @param solutions * @return */ @@ -284,7 +274,6 @@ public class Trainer { } /** - * * @return */ private TrainerParameters getParameters() { @@ -292,7 +281,6 @@ public class Trainer { } /** - * * @param populationSize * @param data * @param expected @@ -305,7 +293,6 @@ public class Trainer { } /** - * * @param population * @param data * @param expected @@ -320,7 +307,6 @@ public class Trainer { } /** - * * @param child */ private void checkAndCorrectNullWeightVector(SolutionDistance child) { diff --git a/src/main/java/be/cylab/java/wowa/training/TrainerParameters.java b/src/main/java/be/cylab/java/wowa/training/TrainerParameters.java index a6208bbd0effd864dda6f07bdb62b4ba0b23e575..a3c14d64189ad7989611a035bdefdd3917b3768a 100644 --- a/src/main/java/be/cylab/java/wowa/training/TrainerParameters.java +++ b/src/main/java/be/cylab/java/wowa/training/TrainerParameters.java @@ -2,6 +2,9 @@ package be.cylab.java.wowa.training; import java.util.logging.Logger; +/** + * Parameters for the Trainer object + */ public class TrainerParameters { public static final int SELECTION_METHOD_RWS = 374; public static final int SELECTION_METHOD_TOS = 942; @@ -20,10 +23,10 @@ public class TrainerParameters { /** * Contains parameters for the WOWA trainer. * - * @param population_size Size of the population for the Genetic Algorithm (greater than 2) - * @param crossover_rate Crossover rate for the genetic algorithm. Percentage of the population kept to generate the next generation (1-99) - * @param mutation_rate Mutation rate for the genetic algorithm. percentage of genes mutated in the next generation (1-99) - * @param selection_method Method to select parents for the next generation. RWS or TOS + * @param population_size Size of the population for the Genetic Algorithm (greater than 2) + * @param crossover_rate Crossover rate for the genetic algorithm. Percentage of the population kept to generate the next generation (1-99) + * @param mutation_rate Mutation rate for the genetic algorithm. percentage of genes mutated in the next generation (1-99) + * @param selection_method Method to select parents for the next generation. RWS or TOS * @param max_generation_number Max generation number before the algorithm stop */ public TrainerParameters( @@ -45,7 +48,7 @@ public class TrainerParameters { } /** - * + * Getter parent_number * @return int, number of parents. Depends on the crossover rate */ public int getNumberParents() { @@ -57,7 +60,6 @@ public class TrainerParameters { } /** - * * @return Logger */ public Logger getLogger() { diff --git a/src/main/java/be/cylab/java/wowa/training/Utils.java b/src/main/java/be/cylab/java/wowa/training/Utils.java index dbff8215f704b0973c8b7f30d16f5de87cc73624..a6fde0b0a3be139ace19af77c7afb8c6d5565648 100644 --- a/src/main/java/be/cylab/java/wowa/training/Utils.java +++ b/src/main/java/be/cylab/java/wowa/training/Utils.java @@ -1,13 +1,10 @@ package be.cylab.java.wowa.training; -import java.lang.reflect.Array; -import java.util.Arrays; import java.util.List; import java.util.Random; public class Utils { /** - * * @param weights * @return */ @@ -21,14 +18,13 @@ public class Utils { } /** - * * @param solutions * @return */ public static double findMaxDistance(final List<SolutionDistance> solutions) { double max = Double.NEGATIVE_INFINITY; for (SolutionDistance solution : solutions) { - if(solution.getDistance() > max) { + if (solution.getDistance() > max) { max = solution.getDistance(); } } @@ -36,14 +32,13 @@ public class Utils { } /** - * * @param solutions * @return */ public static double findMinDistance(final List<SolutionDistance> solutions) { double min = Double.POSITIVE_INFINITY; for (SolutionDistance solution : solutions) { - if (solution.getDistance() < min){ + if (solution.getDistance() < min) { min = solution.getDistance(); } } @@ -51,7 +46,6 @@ public class Utils { } /** - * * @param solutions * @return */ @@ -64,7 +58,6 @@ public class Utils { } /** - * * @param array * @return */ @@ -77,7 +70,6 @@ public class Utils { } /** - * * @param min * @param max * @return diff --git a/src/test/java/be/cylab/java/wowa/training/ExampleTest.java b/src/test/java/be/cylab/java/wowa/training/ExampleTest.java index 38bc1edc9113bef70ce0ff5b048e78073e1f47b9..d0d5d81a494b7f05b589e4f62f172c04c8e4a555 100644 --- a/src/test/java/be/cylab/java/wowa/training/ExampleTest.java +++ b/src/test/java/be/cylab/java/wowa/training/ExampleTest.java @@ -1,21 +1,20 @@ - package be.cylab.java.wowa.training; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import static org.junit.jupiter.api.Assertions.*; + +import static org.junit.jupiter.api.Assertions.assertTrue; /** - * * @author tibo */ public class ExampleTest { - - + + @BeforeEach public void setUp() { } - + @AfterEach public void tearDown() { } @@ -24,5 +23,5 @@ public class ExampleTest { public void testSomeMethod() { assertTrue(true); } - + }