<commit_before>#
# Bare-bones re-implementation of CMA-ES.
#
# This file is part of PINTS (https://github.com/pints-team/pints/) which is
# released under the BSD 3-clause license. See accompanying LICENSE.md for
# copyright notice and full license details.
#
from __future__ import absolute_import, division
from __future__ import print_function, unicode_literals

import numpy as np
import pints
import warnings

from numpy.linalg import norm
from scipy.special import gamma


class BareCMAES(pints.PopulationBasedOptimiser):
    """
    Finds the best parameters using the CMA-ES method described in [1, 2],
    using a bare bones re-implementation.

    For general use, we recommend the :class:`pints.CMAES` optimiser, which
    wraps around the ``cma`` module provided by the authors of CMA-ES. The
    ``cma`` module provides a battle-tested version of the optimiser.

    The role of this class, is to provide a simpler implementation of only the
    core algorithm of CMA-ES, which is easier to read and analyse, and which
    can be used to compare with bare implementations of other methods.

    Extends :class:`PopulationBasedOptimiser`.

    References
    ----------
    .. [1] The CMA Evolution Strategy: A Tutorial
           <NAME>, arxiv
           https://arxiv.org/abs/1604.00772

    .. [2] <NAME>, Koumoutsakos (2006) "Reducing the time complexity
           of the derandomized evolution strategy with covariance matrix
           adaptation (CMA-ES)". Evolutionary Computation
           https://doi.org/10.1162/106365603321828970

    """

    def __init__(self, x0, sigma0=0.1, boundaries=None):
        super(BareCMAES, self).__init__(x0, sigma0, boundaries)

        # Set initial state
        self._running = False
        self._ready_for_tell = False

        # Best solution found
        self._xbest = pints.vector(x0)
        self._fbest = float('inf')

        # Number of iterations run
        self._iterations = 0
<commit_msg>Corrected year in CMAES reference.<commit_after>#
# Bare-bones re-implementation of CMA-ES.
#
# This file is part of PINTS (https://github.com/pints-team/pints/) which is
# released under the BSD 3-clause license. See accompanying LICENSE.md for
# copyright notice and full license details.
#
from __future__ import absolute_import, division
from __future__ import print_function, unicode_literals

import numpy as np
import pints
import warnings

from numpy.linalg import norm
from scipy.special import gamma


class BareCMAES(pints.PopulationBasedOptimiser):
    """
    Finds the best parameters using the CMA-ES method described in [1, 2],
    using a bare bones re-implementation.

    For general use, we recommend the :class:`pints.CMAES` optimiser, which
    wraps around the ``cma`` module provided by the authors of CMA-ES. The
    ``cma`` module provides a battle-tested version of the optimiser.

    The role of this class, is to provide a simpler implementation of only the
    core algorithm of CMA-ES, which is easier to read and analyse, and which
    can be used to compare with bare implementations of other methods.

    Extends :class:`PopulationBasedOptimiser`.

    References
    ----------
    .. [1] The CMA Evolution Strategy: A Tutorial
           <NAME>, arxiv
           https://arxiv.org/abs/1604.00772

    .. [2] <NAME>, Koumoutsakos (2003) "Reducing the time complexity
           of the derandomized evolution strategy with covariance matrix
           adaptation (CMA-ES)". Evolutionary Computation
           https://doi.org/10.1162/106365603321828970

    """

    def __init__(self, x0, sigma0=0.1, boundaries=None):
        super(BareCMAES, self).__init__(x0, sigma0, boundaries)

        # Set initial state
        self._running = False
        self._ready_for_tell = False

        # Best solution found
        self._xbest = pints.vector(x0)
        self._fbest = float('inf')

        # Number of iterations run
        self._iterations = 0

{'fraction_non_alphanumeric': 0.08225765628954695, 'fraction_numerical': 0.025310048089091368, 'mean_word_length': 2.967871485943775, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '950325', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1111, 'n_words': 416}