Skip to content

Commit

Permalink
Roulette Wheel Selection : Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikola-Mircic committed Feb 7, 2024
1 parent ad03c69 commit e2daebb
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions test/genetic_algorithm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,24 @@ using FTN_PSI_PA.GeneticAlgorithm
numOfIterations = 100

population = generatePopulation(populationSize, genesLength, minGene, maxGene)

@testset "Elitistic Selection: " begin
num_gen, best = getAverage(population,
elitistSelection(elitePercent),
mutationPercent,
makeCrossoverFunc([1;3]),
numOfIterations)

num_gen, best = getAverage(population,
elitistSelection(elitePercent),
mutationPercent,
makeCrossoverFunc([1;3]),
numOfIterations)
@test best < 0.1 # Test if the absolute error is smaller than 0.1
end

@test best < 0.1 # Test if the absolute error is smaller than 0.1
@testset "Roulette Wheel Selection: " begin
num_gen, best = getAverage(population,
rouletteWheelSelection(),
mutationPercent,
makeCrossoverFunc([1;3]),
numOfIterations)

@test best < 0.1 # Test if the absolute error is smaller than 0.1
end
end

0 comments on commit e2daebb

Please sign in to comment.