def makeCmaesConfig(populationSize, mu, dim, sd): """Convenience function to configure the 1996 version of CMA-ES """ config = _(populationSize=populationSize, space=EndogeneousProduct(Euclidean(dim=dim), Euclidean(dim=dim * (dim+1) / 2), Euclidean(dim=dim), Euclidean(dim=dim), Euclidean(dim=dim)), sd=sd, mu=mu) config.initial = Cmaes1996Initial(**config.__properties__) return config
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import numpy as np from pyec.distribution.basic import Distribution from pyec.distribution.ec.mutators import * from pyec.distribution.ec.selectors import * from pyec.config import Config as _ from pyec.space import Euclidean, EndogeneousProduct import logging log = logging.getLogger(__file__) """A (1+1)-ES; Note the use of EndogeneousProduct space""" ES1_1 = ( EvolutionStrategySelection[_(mu=1,selection="plus")] << EndogeneousGaussian[_(sd=0.05)] )[_(populationSize=2, space=EndogeneousProduct(Euclidean(dim=5), Euclidean(dim=5)))] """A (10,100)-ES""" ES10_100 = ( EvolutionStrategySelection[_(mu=10)] << EndogeneousGaussian[_(sd=0.05)] )[_(populationSize=100, space=EndogeneousProduct(Euclidean(dim=5), Euclidean(dim=5)))] """A (10/3,100)-ES with intermediate crossover""" IntermediateCrossES10Slash3_100 = ( EvolutionStrategySelection[_(mu=10)] << ((EvolutionStrategySelection[_(mu=10)] >> 1) <<
"""``SimpleGeneticAlgorithm`` uses proportional selection with one point crossover and some mutation, all in a binary encoding such as provided by ``Binary`` and ``BinaryReal``. The following definition says to use proportional selection twice (with the second selection ignoring the results of the first, ``>> 1``), followed by one-point crossover, followed by Bernoulli mutation (bit-flipping). The genotype is set as :class:`BinaryReal` (the ``space``), which generates bit strings and produces a Euclidean phenotype through the ``convert`` method of :class:`BinaryReal`. """ SimpleGeneticAlgorithm = ( Proportional << ((Proportional >> 1) << Crossover[_(crosser=OnePointDualCrosser)]) << Bernoulli )[_(space=BinaryReal(realDim=5))] """``GeneticAlgorithm`` uses tournament selection over the entire population, uniform crossover, and Bernoulli mutation. """ GeneticAlgorithm = ( Tournament << ((Tournament >> 1) << Crossover) << Bernoulli )[_(space=Binary(dim=100))] """``RealGeneticAlgorithm`` uses linear ranking selection, uniform crossover, and Gaussian mutation.