Revisiting the problem of the best selection

Photo by National Cancer Institute on Unsplash
Objective function:
f(P) = ... + 4*troops_ChaosCultists + 52*troops_PlagueMarines + troops_Poxwalkers
Objective function:
f(P) = ... + 4*troops_ChaosCultists + 52*troops_PlagueMarines + troops_Poxwalkers + 5*troops_extra_ChaosCultists + 55*troops_extra_PlagueMarines + 2*troops_extra_Poxwalkers
Restriction:
hq_ChaosLord >= troops_extra_ChaosCultists
hq_ChaosLord >= troops_extra_PlagueMarines
hq_ChaosLord >= troops_extra_Poxwalkers
troops_extra_ChaosCultists + troops_extra_PlagueMarines + troops_extra_Poxwalkers >= hq_ChaosLord
troops_ChaosCultists + troops_extra_ChaosCultists <= 1
troops_PlagueMarines + troops_extra_PlagueMarines <= 1
troops_Poxwalkers + troops_extra_Poxwalkers <= 1
Thomas Splettstoesser (www.scistyle.com), CC BY-SA 4.0 <https://creativecommons.org/licenses/by-sa/4.0>, via Wikimedia Commons
Overview of a Genetic algorithm (adapted from Artificial Intelligence a Modern Approach, Russell & Norvig).
GENETIC-ALGORITHM(population: list of random selections):
do:
new_population = []
for i=1 to size(population):
parent1 = RandomSelect(population)
parent2 = RandomSelect(population)
child = Crossover(parent1, parent2)
if (some_probability) then:
Mutate(child)
new_population.add(child)
population = new_population
while (Fitness is not enought) or (number of generations achieved)
return max(Fitness(population))
Results for 10 experiments with 10 initial random selections and 10 generations, using the TOURNAMENT method.
Results for 10 experiments with 100 initial random selections and 10 generations, , using the TOURNAMENT method.
Results for 10 experiments with 100 initial random selections and 20 generations, , using the ROULETTE method.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store