docstr: Entropy Search acquisition function
  
  In a nutshell entropy search approximates the
  distribution of the global minimum and tries to decrease its
  entropy. See this paper for more details:
      Hennig and C. J. Schuler
      Entropy search for information-efficient global optimization
      Journal of Machine Learning Research, 13, 2012
  
  Current implementation does not provide analytical gradients, thus
  DIRECT optimizer is preferred over gradient descent for this acquisition
  
  Parameters
  ----------
  :param model: GPyOpt class of model
  :param space: GPyOpt class of Design_space
  :param sampler: mcmc sampler for representer points, an instance of util.McmcSampler
  :param optimizer: optimizer of the acquisition. Should be a GPyOpt optimizer
  :param cost_withGradients: function
  :param num_samples: integer determining how many samples to draw for each candidate input
  :param num_representer_points: integer determining how many representer points to sample
  :param proposal_function: Function that defines an unnormalized log proposal measure from which to sample the representer. The default is expected improvement.
  :param burn_in_steps: integer that defines the number of burn-in steps when sampling the representer points
docstr_tok: ["Entropy","Search","acquisition","function","In","a","nutshell","entropy","search","approximates","the","distribution","of","the","global","minimum","and","tries","to","decrease","its","entropy",".","See","this","paper","for","more","details",":","Hennig","and","C.","J.","Schuler","Entropy","search","for","information-efficient","global","optimization","Journal","of","Machine","Learning","Research",",","13",",","2012","Current","implementation","does","not","provide","analytical","gradients",",","thus","DIRECT","optimizer","is","preferred","over","gradient","descent","for","this","acquisition","Parameters","--","--","--","--","--",":","param","model",":","GPyOpt","class","of","model",":","param","space",":","GPyOpt","class","of","Design_space",":","param","sampler",":","mcmc","sampler","for","representer","points",",","an","instance","of","util.McmcSampler",":","param","optimizer",":","optimizer","of","the","acquisition",".","Should","be","a","GPyOpt","optimizer",":","param","cost_withGradients",":","function",":","param","num_samples",":","integer","determining","how","many","samples","to","draw","for","each","candidate","input",":","param","num_representer_points",":","integer","determining","how","many","representer","points","to","sample",":","param","proposal_function",":","Function","that","defines","an","unnormalized","log","proposal","measure","from","which","to","sample","the","representer",".","The","default","is","expected","improvement",".",":","param","burn_in_steps",":","integer","that","defines","the","number","of","burn-in","steps","when","sampling","the","representer","points"]
code: def __init__(
      self,
      model,
      space,
      sampler,
      optimizer=None,
      cost_withGradients=None,
      num_samples=100,
      num_representer_points=50,
      proposal_function=None,
      burn_in_steps=50,
  ):
      """
      Entropy Search acquisition function
  
      In a nutshell entropy search approximates the
      distribution of the global minimum and tries to decrease its
      entropy. See this paper for more details:
          Hennig and C. J. Schuler
          Entropy search for information-efficient global optimization
          Journal of Machine Learning Research, 13, 2012
  
      Current implementation does not provide analytical gradients, thus
      DIRECT optimizer is preferred over gradient descent for this acquisition
  
      Parameters
      ----------
      :param model: GPyOpt class of model
      :param space: GPyOpt class of Design_space
      :param sampler: mcmc sampler for representer points, an instance of util.McmcSampler
      :param optimizer: optimizer of the acquisition. Should be a GPyOpt optimizer
      :param cost_withGradients: function
      :param num_samples: integer determining how many samples to draw for each candidate input
      :param num_representer_points: integer determining how many representer points to sample
      :param proposal_function: Function that defines an unnormalized log proposal measure from which to sample the representer. The default is expected improvement.
      :param burn_in_steps: integer that defines the number of burn-in steps when sampling the representer points
      """
      if not isinstance(model, GPModel):
          raise RuntimeError(
              "The current entropy search implementation supports only GPModel as model"
          )
  
      self.optimizer = optimizer
      self.analytical_gradient_prediction = False
      AcquisitionBase.__init__(
          self,
          model,
          space,
          optimizer,
          cost_withGradients=cost_withGradients,
      )
  
      self.input_dim = self.space.input_dim()
  
      self.num_repr_points = num_representer_points
      self.burn_in_steps = burn_in_steps
      self.sampler = sampler
  
      # (unnormalized) density from which to sample representer points
      self.proposal_function = proposal_function
      if self.proposal_function is None:
          bounds = space.get_bounds()
          mi = np.zeros(len(bounds))
          ma = np.zeros(len(bounds))
          for d in range(len(bounds)):
              mi[d] = bounds[d][0]
              ma[d] = bounds[d][1]
  
          ei = AcquisitionEI(model, space)
  
          def prop_func(x):
              if len(x.shape) != 1:
                  raise ValueError(
                      "Expected a vector, received a matrix of shape {}".format(
                          x.shape
                      )
                  )
              if np.all(np.all(mi <= x)) and np.all(np.all(x <= ma)):
                  return np.log(
                      np.clip(ei._compute_acq(x), 0.0, np.PINF)
                  )
              else:
                  return np.NINF
  
          self.proposal_function = prop_func
  
      # This is used later to calculate derivative of the stochastic part for the loss function
      # Derived following Ito's Lemma, see for example https://en.wikipedia.org/wiki/It%C3%B4%27s_lemma
      self.W = scipy.stats.norm.ppf(
          np.linspace(
              1.0 / (num_samples + 1),
              1 - 1.0 / (num_samples + 1),
              num_samples,
          )
      )[np.newaxis, :]
  
      # Initialize parameters to lazily compute them once needed
      self.repr_points = None
      self.repr_points_log = None
      self.logP = None
  
file_path: GPyOpt/GPyOpt/acquisitions/ES.py
imports: import scipy
  import numpy
  from .base import AcquisitionBase
  from .EI import AcquisitionEI
  from ..util import epmgp
  from ..models.gpmodel import GPModel
label_desc: Use image node_id 1 to create a new AcquisitionEntropySearch object from inherited base classes: AcquisitionBase with example: obj = AcquisitionEntropySearch(model, space, sampler, optimizer, cost_withGradients, num_samples, num_representer_points, proposal_function, burn_in_steps)