Skip to content
Snippets Groups Projects
Commit 180aa3ec authored by a.croix's avatar a.croix
Browse files

Structure improvements

parent 131b996d
No related branches found
No related tags found
No related merge requests found
Pipeline #1030 failed
...@@ -374,7 +374,7 @@ public class Trainer { ...@@ -374,7 +374,7 @@ public class Trainer {
double[] expected double[] expected
) { ) {
List<SolutionDistance> parents = this.selectParents(population, List<SolutionDistance> parents = this.selectParents(population,
this.getParameters().getNumber_of_parents(), this.getParameters().getNumberOfParents(),
this.getParameters().getSelectionMethod()); this.getParameters().getSelectionMethod());
List<SolutionDistance> new_generation = this.doReproduction(parents); List<SolutionDistance> new_generation = this.doReproduction(parents);
List<SolutionDistance> mutated = List<SolutionDistance> mutated =
......
...@@ -64,15 +64,18 @@ public class TrainerParameters { ...@@ -64,15 +64,18 @@ public class TrainerParameters {
} }
/**
public int getNumber_of_parents() { * Getter for number of parents.
return number_of_parents; * @return int
*/
final int getNumberOfParents() {
return this.number_of_parents;
} }
/** /**
* @return Logger * @return Logger
*/ */
final protected Logger getLogger() { final Logger getLogger() {
return logger; return logger;
} }
...@@ -81,7 +84,7 @@ public class TrainerParameters { ...@@ -81,7 +84,7 @@ public class TrainerParameters {
* Getter for population_size. * Getter for population_size.
* @return int * @return int
*/ */
final public int getPopulationSize() { final int getPopulationSize() {
return population_size; return population_size;
} }
...@@ -105,7 +108,8 @@ public class TrainerParameters { ...@@ -105,7 +108,8 @@ public class TrainerParameters {
*/ */
private void setCrossoverRate(final int crossover_rate) { private void setCrossoverRate(final int crossover_rate) {
this.crossover_rate = crossover_rate; this.crossover_rate = crossover_rate;
int nbr_parents = Math.round(this.population_size * (1 - crossover_rate / 100)); int nbr_parents = Math.round(this.population_size
* (1 - crossover_rate / 100));
if (nbr_parents % 2 == 1) { if (nbr_parents % 2 == 1) {
nbr_parents++; nbr_parents++;
} }
...@@ -116,7 +120,7 @@ public class TrainerParameters { ...@@ -116,7 +120,7 @@ public class TrainerParameters {
* Getter for mutation rate. * Getter for mutation rate.
* @return int * @return int
*/ */
public int getMutationRate() { final int getMutationRate() {
return mutation_rate; return mutation_rate;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment