util.pyc
ó
o\c @ s d d l Z d d l Z d d l m Z d d l m Z d d d Z d e f d YZ d Z
d d
Z d d
d YZ
d S( iÿÿÿÿN( t norm( t minimizei iú c s | j | d d
d f | d d
d f d | | j d f } | d d } | | j } | j }
| j | d d
d f | d d
d f d | | j d f } x | D]
} t f d | j d d d | d
d }
|
j sqÅ n |
d k s0|
j d |
k rÅ |
j } |
j d }
qÅ qÅ Wt
j | | d d
d f | d d
d f S( sÓ
A function to find the maximum of the acquisition function
It uses a combination of random sampling (cheap) and the 'L-BFGS-B'
optimization method. First by sampling `n_warmup` (1e5) points at random,
and then running L-BFGS-B from `n_iter` (250) random starting points.
Parameters
----------
:param ac:
The acquisition function object that return its point-wise value.
:param gp:
A gaussian process fitted to the relevant data.
:param y_max:
The current maximum known value of the target function.
:param bounds:
The variables bounds to limit the search of the acq max.
:param random_state:
instance of np.RandomState random number generator
:param n_warmup:
number of times to randomly sample the aquisition function
:param n_iter:
number of times to run scipy.minimize
Returns
-------
:return: x_max, The arg max of the acquisition function.
Ni i t sizet gpt y_maxc s# | j d d d d S( Ni iÿÿÿÿR R ( t reshape( t x( t acR R ( s N:\TCAD\SLALOM\Bayes\util.pyt <lambda>7 s iÿÿÿÿt boundst methods L-BFGS-B( t uniformt shapet argmaxt maxR R t successt Nonet funR t npt clip( R R R R t random_statet n_warmupt n_itert x_triest yst x_maxt max_acqt x_seedst x_tryt res( ( R R R s N:\TCAD\SLALOM\Bayes\util.pyt acq_max s$ %//
t UtilityFunctionc B sM e Z d Z d Z d Z e d Z e d Z e d Z RS( s9
An object to compute the acquisition functions.
c C sI | | _ | | _ | d k r<