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

Solve Clean verify issues. Test erros because of refactoring

parent bcd579fc
No related branches found
No related tags found
1 merge request!6Refactoring
Pipeline #3404 passed
......@@ -143,7 +143,7 @@ public class TrainerParameters {
/**
* @return
*/
public int getCrossoverRate() {
public final int getCrossoverRate() {
return crossover_rate;
}
......
......@@ -14,7 +14,9 @@ class TrainerTest {
@BeforeEach
void setUp() {
TrainerParameters parameters = new TrainerParameters(null, 100, 30, 10, 100, TrainerParameters.SELECTION_METHOD_RWS, TrainerParameters.POPULATION_INITIALIZATION_RANDOM);
TrainerParameters parameters = new TrainerParameters(
null, 100, 30, 10,
100, SelectionMethod.RWS, GenerationMethod.RANDOM);
this.trainer = new Trainer(parameters, new SolutionDistance(5));
}
......@@ -255,13 +257,13 @@ class TrainerTest {
List<Double> expected = generateExpected(100);
List<AbstractSolution> computed_population = this.trainer.computeDistances(population, data, expected);
AbstractSolution best_solution = this.trainer.findBestSolution(computed_population);
List<AbstractSolution> parents = this.trainer.selectParents(computed_population, 30, TrainerParameters.SELECTION_METHOD_TOS);
List<AbstractSolution> parents = this.trainer.selectParents(computed_population, 30, SelectionMethod.TOS);
assertEquals(best_solution, parents.get(0));
assertEquals(30, parents.size());
computed_population = this.trainer.computeDistances(population, data, expected);
best_solution = this.trainer.findBestSolution(computed_population);
parents = this.trainer.selectParents(computed_population, 30, TrainerParameters.SELECTION_METHOD_RWS);
parents = this.trainer.selectParents(computed_population, 30, SelectionMethod.RWS);
assertEquals(best_solution, parents.get(0));
assertEquals(30, parents.size());
......@@ -280,7 +282,7 @@ class TrainerTest {
List<List<Double>> data = generateData(100, 5);
List<Double> expected = generateExpected(100);
population = this.trainer.computeDistances(population, data, expected);
List<AbstractSolution> parents = this.trainer.selectParents(population, 10, TrainerParameters.SELECTION_METHOD_RWS);
List<AbstractSolution> parents = this.trainer.selectParents(population, 10, SelectionMethod.RWS);
this.trainer.reproduce(parents.get(0), parents.get(1), parents, 1, 0.25875);
List<Double> expected_weight_w_child_1 = Arrays.asList(new Double[]{0.29251897956852974, 0.177172118, 0.053456076807862664, 0.35802487078331857, 0.15845805675613056});
List<Double> expected_weight_w_child_2 = Arrays.asList(new Double[] {0.28029560126515357, 0.159332272, 0.08953411511177484, 0.17126082447600055, 0.25994701067132736});
......
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