rbfopt_user_black_box module

Black-box function from user data.

This module contains the definition of a black box function constructed from user data that can be optimized by RBFOpt.

Licensed under Revised BSD license, see LICENSE. (C) Copyright International Business Machines Corporation 2017.

class rbfopt_user_black_box.RbfoptUserBlackBox(dimension, var_lower, var_upper, var_type, obj_funct, obj_funct_noisy=None)[source]

Bases: RbfoptBlackBox

A black-box function from user data that can be optimized.

A class that implements the necessary methods to describe the black-box function to be minimized, and gets all the required data from the user.

Parameters
dimensionint

Dimension of the problem.

var_lower1D numpy.ndarray[float]

Lower bounds of the decision variables.

var_upper1D numpy.ndarray[float]

Upper bounds of the decision variables.

var_type1D numpy.ndarray[char]

An array of length equal to dimension, specifying the type of each variable. Possible types are ‘R’ for real (continuous) variables, ‘I’ for integer (discrete, ordered) variables, ‘C’ for categorical (discrete, unordered) variables. Bounds for categorical variables are interpreted the same way as for integer variables, but categorical variables are handled differently by the optimization algorithm; e.g., a categorical variable with bounds [2, 4] can take the value 2, 3 or 4.

obj_functCallable[1D numpy.ndarray[float]]

The function to optimize. Must take a numpy array as argument, and return a float.

obj_funct_noisyCallable[1D numpy.ndarray[float]] or None

The noisy but fast version of the function to optimize. If given, it must take a numpy array as argument, and return a numpy array with three floats, in the following order: the approximate function value, its lower variation, and its upper variation, where where lower <= 0 and upper >= 0 and the true function value is contained between value + lower and value + upper. If it is None, we assume that there is no fast version of the objective function.

See also

rbfopt_black_box.BlackBox
evaluate(x)[source]

Evaluate the black-box function.

Parameters
xList[float]

Value of the decision variables.

Returns
float

Value of the function at x.

evaluate_noisy(x)[source]

Evaluate a fast approximation of the black-box function.

Returns an approximation of the value of evaluate(), hopefully much more quickly, and provides error bounds on the evaluation. If has_evaluate_noisy() returns False, this function will never be queried and therefore it does not have to return any value.

Parameters
x1D numpy.ndarray[float]

Value of the decision variables.

Returns
1D numpy.ndarray[float]

A numpy array with three floats (value, lower, upper) containing the approximate value of the function at x, the lower error bound, and the upper error bound, such that the true function value is contained between value + lower and value + upper. Hence, lower should be <= 0 while upper should be >= 0.

get_dimension()[source]

Return the dimension of the problem.

Returns
int

The dimension of the problem.

get_var_lower()[source]

Return the array of lower bounds on the variables.

Returns
List[float]

Lower bounds of the decision variables.

get_var_type()[source]

Return the type of each variable.

Returns
1D numpy.ndarray[char]

An array of length equal to dimension, specifying the type of each variable. Possible types are ‘R’ for real (continuous) variables, ‘I’ for integer (discrete) variables, ‘C’ for categorical (discrete, unordered). Bounds for categorical variables are interpreted the same way as for integer variables, but categorical variables are handled differently by the optimization algorithm; e.g., a categorical variable with bounds [2, 4] can take the value 2, 3 or 4.

get_var_upper()[source]

Return the array of upper bounds on the variables.

Returns
List[float]

Upper bounds of the decision variables.

has_evaluate_noisy()[source]

Indicate whether evaluate_noisy is available.

Indicate if a fast but potentially noisy version of evaluate is available through the function evaluate_noisy. If True, such function will be used to try to accelerate convergence of the optimization algorithm. If False, the function evaluate_noisy will never be queried.

Returns
bool

Is evaluate_noisy available?