Search code examples
pythondeapparticle-swarm

DEAP framework Python usage of "n=5" in PSO


What is the meaning of n in this code which is given as default in DEAP without an explanation in basic PSO?

pop = toolbox.population(n=5)

def main():
    pop = toolbox.population(n=5)
    stats = tools.Statistics(lambda ind: ind.fitness.values)
    stats.register("avg", numpy.mean)
    stats.register("std", numpy.std)
    stats.register("min", numpy.min)
    stats.register("max", numpy.max)

    logbook = tools.Logbook()
    logbook.header = ["gen", "evals"] + stats.fields

    # STUFF #

    return pop, logbook, best

Solution

  • After my discussion with a DEAP enthusiast, n turned out to be the size of the population. So n = 5 means, DEAP will generate 5 individual for the first generation.