# Path: opentuner/search/technique.py
# class SearchTechnique(SearchPlugin, SearchTechniqueBase):
#     """
#     a search search technique with basic utility functions
#     """
# 
#     def __init__(self, *pargs, **kwargs):
#         super(SearchTechnique, self).__init__(*pargs, **kwargs)
#         self.driver = None
#         self.manipulator = None
#         self.objective = None
#         self.request_count = 0
# 
#     def set_driver(self, driver):
#         super(SearchTechnique, self).set_driver(driver)
#         self.manipulator = driver.manipulator
#         self.objective = driver.objective
#         driver.add_plugin(self)
# 
#     def desired_result(self):
#         """
#         create and return a resultsdb.models.DesiredResult
#         returns None if no desired results and False if waiting for results
#         """
#         cfg = self.desired_configuration()
#         if cfg is None:
#             return None
#         if cfg is False:
#             return False
#         if type(cfg) is Configuration:
#             config = cfg
#         else:
#             config = self.driver.get_configuration(cfg)
#         desired = DesiredResult(configuration=config,
#                                 requestor=self.name,
#                                 generation=self.driver.generation,
#                                 request_date=datetime.now(),
#                                 tuning_run=self.driver.tuning_run)
#         if hasattr(self, 'limit'):
#             desired.limit = self.limit
#         self.driver.register_result_callback(desired, self.handle_requested_result)
#         self.request_count += 1
#         return desired
# 
#     @abc.abstractmethod
#     def desired_configuration(self):
#         """
#         return a cfg that we should test
#         given a ConfigurationManipulator and SearchDriver
#         return None if there are no configurations to test
#         return False if waiting for results
#         """
#         return dict()
# 
#     def handle_requested_result(self, result):
#         """called for each new Result(), regardless of who requested it"""
#         pass
# 
#     def default_generated_name(self):
#         """ The default generated name for this technique """
#         return self.base_name()
# 
#     def use_default_generated_name(self):
#         """ set the name of this technique to the default generated name """
#         self.name = self.default_generated_name()
# 
#     def base_name(self):
#         """
#         Return the base name of this technique with form
#         classname;hyperparam1,v1;hyperparam2,v2 ...
#         where hyperparams are taken in order from get_hyper_parameters()
# 
#         Should only be called after this technique has finished initializing.
#         """
#         out = [self.__class__.__name__]
#         for hyper_parameter in self.get_hyper_parameters():
#             # get hyperparam,v as a string and append
#             try:
#                 out.append(hyper_parameter + ',' + str(getattr(self, hyper_parameter)))
#             except AttributeError:
#                 log.error("Uninitialized hyper-parameter %s for technique %s.",
#                           hyper_parameter, self.__class__.__name__)
# 
#         return ';'.join(out)
# 
#     @classmethod
#     def get_hyper_parameters(cls):
#         """
#         return a list of hyper-parameters names for this technique
# 
#         Name strings must match the corresponding attribute with the hyper-parameter
#         value on technique instances. Names should also match the key word argument
#         used when initializing an instance. Hyperparameters should only take literal
#         values.
# 
#         For example, given hyper parameter "mutation_rate", then the __init__ method
#         should have 'mutation_rate' as a key word argument and later have the line
#         self.mutation_rate = mutation_rate
#         """
#         return []
# 
#     @classmethod
#     def generate_technique(cls, manipulator=None, *args, **kwargs):
#         """ return a new technique based off this instance """
#         t = cls(*args, **kwargs)
#         t.use_default_generated_name()
#         return t
# 
# Path: opentuner/search/technique.py
# def register(t):
#     the_registry.append(t)


import logging
import random
import time
from builtins import map
from builtins import object
from builtins import range
from fn import _
from past.utils import old_div
from .technique import SearchTechnique
from .technique import register
from __future__ import absolute_import
from __future__ import division




log = logging.getLogger(__name__)
log.setLevel(logging.WARNING)


class PopulationMember(object):
    def __init__(self, config, submitted=True):
        self.config = config
        self.submitted = submitted
        self.timestamp = time.time()
        self.candidate_replacement = None

    def touch(self):

# Path: opentuner/search/technique.py
# class SearchTechnique(SearchPlugin, SearchTechniqueBase):
#     """
#     a search search technique with basic utility functions
#     """
# 
#     def __init__(self, *pargs, **kwargs):
#         super(SearchTechnique, self).__init__(*pargs, **kwargs)
#         self.driver = None
#         self.manipulator = None
#         self.objective = None
#         self.request_count = 0
# 
#     def set_driver(self, driver):
#         super(SearchTechnique, self).set_driver(driver)
#         self.manipulator = driver.manipulator
#         self.objective = driver.objective
#         driver.add_plugin(self)
# 
#     def desired_result(self):
#         """
#         create and return a resultsdb.models.DesiredResult
#         returns None if no desired results and False if waiting for results
#         """
#         cfg = self.desired_configuration()
#         if cfg is None:
#             return None
#         if cfg is False:
#             return False
#         if type(cfg) is Configuration:
#             config = cfg
#         else:
#             config = self.driver.get_configuration(cfg)
#         desired = DesiredResult(configuration=config,
#                                 requestor=self.name,
#                                 generation=self.driver.generation,
#                                 request_date=datetime.now(),
#                                 tuning_run=self.driver.tuning_run)
#         if hasattr(self, 'limit'):
#             desired.limit = self.limit
#         self.driver.register_result_callback(desired, self.handle_requested_result)
#         self.request_count += 1
#         return desired
# 
#     @abc.abstractmethod
#     def desired_configuration(self):
#         """
#         return a cfg that we should test
#         given a ConfigurationManipulator and SearchDriver
#         return None if there are no configurations to test
#         return False if waiting for results
#         """
#         return dict()
# 
#     def handle_requested_result(self, result):
#         """called for each new Result(), regardless of who requested it"""
#         pass
# 
#     def default_generated_name(self):
#         """ The default generated name for this technique """
#         return self.base_name()
# 
#     def use_default_generated_name(self):
#         """ set the name of this technique to the default generated name """
#         self.name = self.default_generated_name()
# 
#     def base_name(self):
#         """
#         Return the base name of this technique with form
#         classname;hyperparam1,v1;hyperparam2,v2 ...
#         where hyperparams are taken in order from get_hyper_parameters()
# 
#         Should only be called after this technique has finished initializing.
#         """
#         out = [self.__class__.__name__]
#         for hyper_parameter in self.get_hyper_parameters():
#             # get hyperparam,v as a string and append
#             try:
#                 out.append(hyper_parameter + ',' + str(getattr(self, hyper_parameter)))
#             except AttributeError:
#                 log.error("Uninitialized hyper-parameter %s for technique %s.",
#                           hyper_parameter, self.__class__.__name__)
# 
#         return ';'.join(out)
# 
#     @classmethod
#     def get_hyper_parameters(cls):
#         """
#         return a list of hyper-parameters names for this technique
# 
#         Name strings must match the corresponding attribute with the hyper-parameter
#         value on technique instances. Names should also match the key word argument
#         used when initializing an instance. Hyperparameters should only take literal
#         values.
# 
#         For example, given hyper parameter "mutation_rate", then the __init__ method
#         should have 'mutation_rate' as a key word argument and later have the line
#         self.mutation_rate = mutation_rate
#         """
#         return []
# 
#     @classmethod
#     def generate_technique(cls, manipulator=None, *args, **kwargs):
#         """ return a new technique based off this instance """
#         t = cls(*args, **kwargs)
#         t.use_default_generated_name()
#         return t
# 
# Path: opentuner/search/technique.py
# def register(t):
#     the_registry.append(t)


# Path: opentuner/search/differentialevolution.py
import logging
import random
import time
from builtins import map
from builtins import object
from builtins import range
from fn import _
from past.utils import old_div
from .technique import SearchTechnique
from .technique import register

from __future__ import absolute_import
from __future__ import division




log = logging.getLogger(__name__)
log.setLevel(logging.WARNING)


class PopulationMember(object):
    def __init__(self, config, submitted=True):
        self.config = config
        self.submitted = submitted
        self.timestamp = time.time()
        self.candidate_replacement = None

    def touch(self):

        self.timestamp = time.time()