DEAP / deap

Distributed Evolutionary Algorithms in Python
http://deap.readthedocs.org/
GNU Lesser General Public License v3.0
5.79k stars 1.12k forks source link

Fitness vs Evaluate #178

Closed ido4848 closed 7 years ago

ido4848 commented 7 years ago

Hello, i'm newbie to DEAP. I wonder what's the meaning of an individual's fitness, as seen here in the one max example:

creator.create("FitnessMax", base.Fitness, weights=(1.0,) creator.create("Individual", list, fitness=creator.FitnessMax)

versus

def evaluate(individual): return sum(individual), toolbox.register("evaluate", evaluate)

because i see that the usage is as following:

fitnesses = list(map(toolbox.evaluate, pop))

so fitness is the value of evaluate? then, what's the role of fitness? when is it used? (i'm referring to the FitnessMax sutff)

This is an issue because i think it is not fully explained in the docs. Thank's.

fmder commented 7 years ago

The FitnessMax is an attribute attached to an individual meaning its goodness. It also indicates whether the problem is minimization or maximization.

The fitnesses are the fitness values for each individual as given by the evaluation function. Since we didn't wanted the user to worry about implentation details, and certainly not wanted him to modify the individuals during evaluation, the simplest evaluation function returns a fitness the we attach later to an individual.fitness.value.

DEAP's documentation is not meant as an introduction to evolutionary algorithms. As an introduction we refer to these two excellent books: