This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def varOr(toolbox, population, lambda_, cxpb, mutpb): | |
assert (cxpb + mutpb) <= 1.0, ("The sum of the crossover and mutation " | |
"probabilities must be smaller or equal to 1.0.") | |
ncx, nmut, nrep = numpy.random.multinomial(lambda_, (cxpb, mutpb, 1-cxpb-mutpb)) | |
offcx = map(toolbox.clone, tools.selRandom(population, 2*ncx)) | |
offmut = map(toolbox.clone, tools.selRandom(population, nmut)) | |
offrep = map(toolbox.clone, tools.selRandom(population, nrep)) | |
for ind1, ind2 in offcx: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def eaGenerateUpdate(toolbox, ngen, halloffame=None, stats=None, verbose=True): | |
"""The CMA-ES algorithm as described in Hansen, N. (2006). *The CMA | |
Evolution Strategy: A Comparing Rewiew.* | |
:param toolbox: A :class:`~deap.base.Toolbox` that contains the evolution | |
operators. | |
:param ngen: The number of generation. | |
:param stats: A :class:`~deap.tools.Statistics` object that is updated | |
inplace, optional. | |
:param halloffame: A :class:`~deap.tools.HallOfFame` object that will |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Strategy(base.Toolbox): | |
""" | |
A strategy that will keep track of the basic parameters of the CMA-ES | |
algorithm. | |
:param centroid: An iterable object that indicates where to start the | |
evolution. | |
:param sigma: The list of initial standard deviations of the distribution, | |
it shall be the same length than the centroid. | |
:param parameter: One or more parameter to pass to the strategy as |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
from deap import algorithms | |
from deap import base | |
from deap import benchmarks | |
from deap import cma | |
from deap import creator | |
from deap import tools | |
# Problem size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is part of DEAP. | |
# | |
# DEAP is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Lesser General Public License as | |
# published by the Free Software Foundation, either version 3 of | |
# the License, or (at your option) any later version. | |
# | |
# DEAP is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is part of DEAP. | |
# | |
# DEAP is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Lesser General Public License as | |
# published by the Free Software Foundation, either version 3 of | |
# the License, or (at your option) any later version. | |
# | |
# DEAP is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gp | |
import random | |
__type__ = None | |
class PrimitiveTree(list): | |
def __init__(self, content): | |
self[:] = content | |
@property |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is part of EAP. | |
# | |
# EAP is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Lesser General Public License as | |
# published by the Free Software Foundation, either version 3 of | |
# the License, or (at your option) any later version. | |
# | |
# EAP is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is part of DEAP. | |
# | |
# DEAP is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Lesser General Public License as | |
# published by the Free Software Foundation, either version 3 of | |
# the License, or (at your option) any later version. | |
# | |
# DEAP is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import array | |
import pycec2013 | |
from scoop import futures | |
if __name__ == "__main__": | |
bench = pycec2013.Benchmark(1) | |
pop = [array.array('d', [1.0]), array.array('d', [2.0]), array.array('d', [3.0])] | |
print(list(futures.map(bench.evaluate, pop))) | |
# print(list(map(bench.evaluate, pop))) |
OlderNewer