# Interfaces¶

## Domain¶

class gpflowopt.domain.Domain(parameters)

A domain representing the mathematical space over which is optimized.

Attributes: highest_parent A reference to the top of the tree, usually a Model instance long_name This is a unique identifier for a param object within a structure, made by concatenating the names through the tree. lower Lower bound of the domain, corresponding to a numpy array with the lower value of each parameter name An automatically generated name, given by the reference of the _parent to this instance. size Returns the dimensionality of the domain upper Upper bound of the domain, corresponding to a numpy array with the upper value of each parameter value
class gpflowopt.domain.Parameter(label, xinit)

Abstract class representing a parameter (which corresponds to a one-dimensional domain) This class can be derived for continuous, discrete and categorical parameters

Attributes: highest_parent A reference to the top of the tree, usually a Model instance long_name This is a unique identifier for a param object within a structure, made by concatenating the names through the tree. lower Lower bound of the domain, corresponding to a numpy array with the lower value of each parameter name An automatically generated name, given by the reference of the _parent to this instance. size One parameter has a dimensionality of 1 upper Upper bound of the domain, corresponding to a numpy array with the upper value of each parameter value

## Optimizer¶

class gpflowopt.optim.Optimizer(domain, exclude_gradient=False)

An optimization algorithm.

Starts from an initial (set of) point(s) it performs an optimization over a domain. May be gradient-based or gradient-free.

Attributes: domain The current domain the optimizer operates on.

Methods

 get_initial() Return the initial set of points. gradient_enabled() Returns if the optimizer is a gradient-based algorithm or not. optimize(objectivefx, **kwargs) Optimize a given function f over a domain. set_initial(initial) Set the initial set of points. silent() Context for performing actions on an optimizer (such as optimize) with all stdout discarded.

## Acquisition¶

class gpflowopt.acquisition.Acquisition(models=[], optimize_restarts=5)

An acquisition function maps the belief represented by a Bayesian model into a score indicating how promising a point is for evaluation.

In Bayesian Optimization this function is typically optimized over the optimization domain to determine the next point for evaluation. An object of this class holds a list of GPflow models. Subclasses implement a build_acquisition function which computes the acquisition function (usually from the predictive distribution) using TensorFlow. Optionally, a method setup can be implemented which computes some quantities which are used to compute the acquisition, but do not depend on candidate points.

Acquisition functions can be combined through addition or multiplication to construct joint criteria. For instance, for constrained optimization. The objects then form a tree hierarchy.

Acquisition models implement a lazy strategy to optimize models and run setup. This is implemented by a _needs_setup attribute (similar to the _needs_recompile in GPflow). Calling set_data() sets this flag to True. Calling methods marked with the setup_require decorator (such as evaluate) optimize all models, then call setup if this flag is set. In hierarchies, first acquisition objects handling constraint objectives are set up, then the objects handling objectives.

Attributes: data The training data of the models. data_holders Return a list of all the child DataHolders fixed A boolean attribute to determine if all the child parameters of this node are fixed highest_parent A reference to the top of the tree, usually a Model instance long_name This is a unique identifier for a param object within a structure, made by concatenating the names through the tree. models The GPflow models representing our beliefs of the optimization problem. name An automatically generated name, given by the reference of the _parent to this instance. sorted_params Return a list of all the child parameters, sorted by id.

Methods

 build_prior() Build a tf expression for the prior by summing all child-parameter priors. constraint_indices() Method returning the indices of the model outputs which correspond to the (expensive) constraint functions. enable_scaling(domain) Enables and configures the DataScaler objects wrapping the GP models. evaluate(Xcand) AutoFlow method to compute the acquisition scores for candidates, without returning the gradients. evaluate_with_gradients(Xcand) AutoFlow method to compute the acquisition scores for candidates, also returns the gradients. feasible_data_index() Returns a boolean array indicating which data points are considered feasible (according to the acquisition function(s) ) and which not. get_feed_dict_keys() Recursively generate a dictionary of {object: _tf_array} pairs that can be used in update_feed_dict get_free_state() Recurse get_free_state on all child parameters, and hstack them. get_param_index(param_to_index) Given a parameter, compute the position of that parameter on the free-state vector. get_samples_df(samples) Given a numpy array where each row is a valid free-state vector, return a pandas.DataFrame which contains the parameter name and associated samples in the correct form (e.g. make_tf_array(X) Distribute a flat tensorflow array amongst all the child parameter of this instance. objective_indices() Method returning the indices of the model outputs which are objective functions. randomize([distributions, skipfixed]) Calls randomize on all parameters in model hierarchy. set_data(X, Y) Update the training data of the contained models set_state(x) Set the values of all the parameters by recursion tf_mode() A context for building models.
 build_acquisition get_parameter_dict set_parameter_dict update_feed_dict

## Design¶

class gpflowopt.design.Design(size, domain)

Design of size N (number of points) generated within a D-dimensional domain.

Users should call generate() which auto-scales the design to the domain specified in the constructor. To implement new design methodologies subclasses should implement create_design(), which returns the design on the domain specified by the generative_domain method (which defaults to a unit cube).

Attributes:
generative_domain
return: Domain object representing the domain associated with the points generated in create_design().

Methods

 create_design() Returns a design generated in the generative domain. generate() Creates the design in the domain specified during construction.

## Transform¶

class gpflowopt.transforms.DataTransform

Maps data in Domain U to Domain V.

Useful for scaling of data between domains.

Attributes: data_holders Return a list of all the child DataHolders fixed A boolean attribute to determine if all the child parameters of this node are fixed highest_parent A reference to the top of the tree, usually a Model instance long_name This is a unique identifier for a param object within a structure, made by concatenating the names through the tree. name An automatically generated name, given by the reference of the _parent to this instance. sorted_params Return a list of all the child parameters, sorted by id.

Methods

 backward(Y) Performs the transformation of V -> U. build_forward(X) Tensorflow graph for the transformation of U -> V build_prior() Build a tf expression for the prior by summing all child-parameter priors. forward(X) Performs the transformation of U -> V get_feed_dict_keys() Recursively generate a dictionary of {object: _tf_array} pairs that can be used in update_feed_dict get_free_state() Recurse get_free_state on all child parameters, and hstack them. get_param_index(param_to_index) Given a parameter, compute the position of that parameter on the free-state vector. get_samples_df(samples) Given a numpy array where each row is a valid free-state vector, return a pandas.DataFrame which contains the parameter name and associated samples in the correct form (e.g. make_tf_array(X) Distribute a flat tensorflow array amongst all the child parameter of this instance. randomize([distributions, skipfixed]) Calls randomize on all parameters in model hierarchy. set_state(x) Set the values of all the parameters by recursion tf_mode() A context for building models.
 assign get_parameter_dict set_parameter_dict update_feed_dict

## ModelWrapper¶

class gpflowopt.models.ModelWrapper(model)

Class for fast implementation of a wrapper for models defined in GPflow.

Once wrapped, all lookups for attributes which are not found in the wrapper class are automatically forwarded to the wrapped model. To influence the I/O of methods on the wrapped class, simply implement the method in the wrapper and call the appropriate methods on the wrapped class. Specific logic is included to make sure that if AutoFlow methods are influenced following this pattern, the original AF storage (if existing) is unaffected and a new storage is added to the subclass.

Attributes: data_holders Return a list of all the child DataHolders fixed A boolean attribute to determine if all the child parameters of this node are fixed highest_parent Returns an instance of the ParentHook instead of the usual reference to a Parentable. long_name This is a unique identifier for a param object within a structure, made by concatenating the names through the tree. name An automatically generated name, given by the reference of the _parent to this instance. sorted_params Return a list of all the child parameters, sorted by id.

Methods

 build_prior() Build a tf expression for the prior by summing all child-parameter priors. get_feed_dict_keys() Recursively generate a dictionary of {object: _tf_array} pairs that can be used in update_feed_dict get_free_state() Recurse get_free_state on all child parameters, and hstack them. get_param_index(param_to_index) Given a parameter, compute the position of that parameter on the free-state vector. get_samples_df(samples) Given a numpy array where each row is a valid free-state vector, return a pandas.DataFrame which contains the parameter name and associated samples in the correct form (e.g. make_tf_array(X) Distribute a flat tensorflow array amongst all the child parameter of this instance. randomize([distributions, skipfixed]) Calls randomize on all parameters in model hierarchy. set_state(x) Set the values of all the parameters by recursion tf_mode() A context for building models.
 get_parameter_dict set_parameter_dict update_feed_dict
__eq__(other)

Return self==value.

__getattr__(item)

If an attribute is not found in this class, it is searched in the wrapped model

__init__(model)
Parameters: model – model to be wrapped
__setattr__(key, value)
1. If setting wrapped attribute, point parent to this object (the ModelWrapper).
2. Setting attributes in the right objects. The following rules are processed in order: (a) If attribute exists in wrapper, set in wrapper. (b) If no object has been wrapped (wrapper is None), set attribute in the wrapper. (c) If attribute is found in the wrapped object, set it there. This rule is ignored for AF storages. (d) Set attribute in wrapper.
highest_parent

Returns an instance of the ParentHook instead of the usual reference to a Parentable.

name

An automatically generated name, given by the reference of the _parent to this instance.