Objectives
categorical
ConstrainedCategoricalObjective
Bases: ConstrainedObjective
, Objective
Compute the categorical objective value as:
Po where P is an [n, c] matrix where each row is a probability vector
(P[i, :].sum()=1 for all i) and o is a vector of size [c] of objective values
Attributes:
Name | Type | Description |
---|---|---|
w |
float
|
float between zero and one for weighting the objective. |
desirability |
list
|
list of values of size c (c is number of categories) such that the i-th entry is in {True, False} |
Source code in bofire/data_models/objectives/categorical.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
__call__(x, x_adapt=None)
The call function returning a probabilistic reward for x.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
A matrix of x values |
required |
x_adapt
|
Optional[ndarray]
|
An array of x values which are used to update the objective parameters on the fly. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Union[Series, ndarray, float]
|
np.ndarray: A reward calculated as inner product of probabilities and feasible objectives. |
Source code in bofire/data_models/objectives/categorical.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
from_dict_label()
Returns the label location and the categories
Source code in bofire/data_models/objectives/categorical.py
60 61 62 63 |
|
to_dict()
Returns the categories and corresponding objective values as dictionary
Source code in bofire/data_models/objectives/categorical.py
52 53 54 |
|
to_dict_label()
Returns the categories and label location of categories
Source code in bofire/data_models/objectives/categorical.py
56 57 58 |
|
validate_desireability()
Validates that categories have unique names
Parameters:
Name | Type | Description | Default |
---|---|---|---|
categories
|
List[str]
|
List or tuple of category names |
required |
Raises:
Type | Description |
---|---|
ValueError
|
when categories do not match objective categories |
Returns:
Type | Description |
---|---|
Tuple[str]: Tuple of the categories |
Source code in bofire/data_models/objectives/categorical.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
desirabilities
DecreasingDesirabilityObjective
Bases: DesirabilityObjective
An objective returning a reward the negative, shifted scaled identity, but trimmed at the bounds:
d = ((upper_bound - x) / (upper_bound - lower_bound))^t
where:
t = exp(log_shape_factor)
Note, that with clipping the reward is always between zero and one.
Attributes:
Name | Type | Description |
---|---|---|
clip |
bool
|
Whether to clip the values below/above the lower/upper bound, by default True. |
log_shape_factor |
float
|
Logarithm of the shape factor: Whether the interpolation between the lower bound and the upper is linear (=0), convex (>0) or concave (<0) , by default 0.0. |
w |
float
|
relative weight, by default = 1. |
bounds |
tuple[float]
|
lower and upper bound of the desirability. Below bounds[0] the desirability is =1 (if clip=True) or >1 (if clip=False). Above bounds[1] the desirability is =0 (if clip=True) or <0 (if clip=False). Defaults to (0, 1). |
Source code in bofire/data_models/objectives/desirabilities.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
DesirabilityObjective
Bases: IdentityObjective
Abstract class for desirability objectives. Works as Identity Objective
Source code in bofire/data_models/objectives/desirabilities.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
__call__(x, x_adapt)
Wrapper function for to call numpy and torch functions with series or numpy arrays. matches call signature of objectives.
Source code in bofire/data_models/objectives/desirabilities.py
34 35 36 37 38 39 40 41 42 43 |
|
IncreasingDesirabilityObjective
Bases: DesirabilityObjective
An objective returning a reward the scaled identity, but trimmed at the bounds:
d = ((x - lower_bound) / (upper_bound - lower_bound))^t
if clip is True, the reward is zero for x < lower_bound and one for x > upper_bound.
where:
t = exp(log_shape_factor)
Note, that with clipping the reward is always between zero and one.
Attributes:
Name | Type | Description |
---|---|---|
clip |
bool
|
Whether to clip the values below/above the lower/upper bound, by default True. |
log_shape_factor |
float
|
Logarithm of the shape factor: Whether the interpolation between the lower bound and the upper is linear (=0), convex (>0) or concave (<0) , by default 0.0. |
w |
float
|
relative weight, by default = 1. |
bounds |
tuple[float]
|
lower and upper bound of the desirability. Below bounds[0] the desirability is =0 (if clip=True) or <0 (if clip=False). Above bounds[1] the desirability is =1 (if clip=True) or >1 (if clip=False). Defaults to (0, 1). |
Source code in bofire/data_models/objectives/desirabilities.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
PeakDesirabilityObjective
Bases: DesirabilityObjective
A piecewise (linear or convex/concave) objective that increases from the lower bound to the peak position and decreases from the peak position to the upper bound.
Attributes:
Name | Type | Description |
---|---|---|
clip |
bool
|
Whether to clip the values below/above the lower/upper bound, by default True. |
log_shape_factor |
float
|
Logarithm of the shape factor for the increasing part: Whether the interpolation between the lower bound and the peak is linear (=0), convex (>1) or concave (<1) , by default 0.0. |
log_shape_factor_decreasing |
float
|
Logarithm of the shape factor for the decreasing part. Whether the interpolation between the peak and the upper bound is linear (=0), convex (>0) or concave (<0), by default 0.0. |
peak_position |
float
|
Position of the peak, by default 0.5. |
w |
float
|
relative weight: desirability, when x=peak_position, by default = 1. |
bounds |
tuple[float]
|
lower and upper bound of the desirability. Below bounds[0] the desirability is =0 (if clip=True) or <0 (if clip=False). Above bounds[1] the desirability is =0 (if clip=True) or <0 (if clip=False). Defaults to (0, 1). |
Source code in bofire/data_models/objectives/desirabilities.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
identity
IdentityObjective
Bases: Objective
An objective returning the identity as reward. The return can be scaled, when a lower and upper bound are provided.
Attributes:
Name | Type | Description |
---|---|---|
w |
float
|
float between zero and one for weighting the objective |
bounds |
Tuple[float]
|
Bound for normalizing the objective between zero and one. Defaults to (0,1). |
Source code in bofire/data_models/objectives/identity.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
__call__(x, x_adapt=None)
The call function returning a reward for passed x values
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
An array of x values |
required |
x_adapt
|
Optional[ndarray]
|
An array of x values which are used to update the objective parameters on the fly. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Union[Series, ndarray]
|
np.ndarray: The identity as reward, might be normalized to the passed lower and upper bounds |
Source code in bofire/data_models/objectives/identity.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
validate_lower_upper(bounds)
classmethod
Validation function to ensure that lower bound is always greater the upper bound
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Dict
|
The attributes of the class |
required |
Raises:
Type | Description |
---|---|
ValueError
|
when a lower bound higher than the upper bound is passed |
Returns:
Name | Type | Description |
---|---|---|
Dict |
The attributes of the class |
Source code in bofire/data_models/objectives/identity.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
MaximizeObjective
Bases: IdentityObjective
Child class from the identity function without modifications, since the parent class is already defined as maximization
Attributes:
Name | Type | Description |
---|---|---|
w |
float
|
float between zero and one for weighting the objective |
bounds |
Tuple[float]
|
Bound for normalizing the objective between zero and one. Defaults to (0,1). |
Source code in bofire/data_models/objectives/identity.py
73 74 75 76 77 78 79 80 81 82 |
|
MinimizeObjective
Bases: IdentityObjective
Class returning the negative identity as reward.
Attributes:
Name | Type | Description |
---|---|---|
w |
float
|
float between zero and one for weighting the objective |
bounds |
Tuple[float]
|
Bound for normalizing the objective between zero and one. Defaults to (0,1). |
Source code in bofire/data_models/objectives/identity.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
__call__(x, x_adapt=None)
The call function returning a reward for passed x values
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
An array of x values |
required |
x_adapt
|
Optional[ndarray]
|
An array of x values which are used to update the objective parameters on the fly. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Union[Series, ndarray]
|
np.ndarray: The negative identity as reward, might be normalized to the passed lower and upper bounds |
Source code in bofire/data_models/objectives/identity.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
objective
ConstrainedObjective
This abstract class offers a convenience routine for transforming sigmoid based objectives to botorch output constraints.
Source code in bofire/data_models/objectives/objective.py
36 37 |
|
Objective
Bases: BaseModel
The base class for all objectives
Source code in bofire/data_models/objectives/objective.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
__call__(x, x_adapt=None)
abstractmethod
Abstract method to define the call function for the class Objective
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
An array of x values for which the objective should be evaluated. |
required |
x_adapt
|
Optional[ndarray]
|
An array of x values which are used to update the objective parameters on the fly. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Union[Series, ndarray]
|
np.ndarray: The desirability of the passed x values |
Source code in bofire/data_models/objectives/objective.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
sigmoid
MaximizeSigmoidObjective
Bases: SigmoidObjective
Class for a maximizing sigmoid objective
Attributes:
Name | Type | Description |
---|---|---|
w |
float
|
float between zero and one for weighting the objective. |
steepness |
float
|
Steepness of the sigmoid function. Has to be greater than zero. |
tp |
float
|
Turning point of the sigmoid function. |
Source code in bofire/data_models/objectives/sigmoid.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
__call__(x, x_adapt=None)
The call function returning a sigmoid shaped reward for passed x values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
An array of x values |
required |
x_adapt
|
ndarray
|
An array of x values which are used to update the objective parameters on the fly. |
None
|
Returns:
Type | Description |
---|---|
Union[Series, ndarray]
|
np.ndarray: A reward calculated with a sigmoid function. The stepness and the tipping point can be modified via passed arguments. |
Source code in bofire/data_models/objectives/sigmoid.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
MinimizeSigmoidObjective
Bases: SigmoidObjective
Class for a minimizing a sigmoid objective
Attributes:
Name | Type | Description |
---|---|---|
w |
float
|
float between zero and one for weighting the objective. |
steepness |
float
|
Steepness of the sigmoid function. Has to be greater than zero. |
tp |
float
|
Turning point of the sigmoid function. |
Source code in bofire/data_models/objectives/sigmoid.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
__call__(x, x_adapt=None)
The call function returning a sigmoid shaped reward for passed x values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
An array of x values |
required |
x_adapt
|
ndarray
|
An array of x values which are used to update the objective parameters on the fly. |
None
|
Returns:
Type | Description |
---|---|
Union[Series, ndarray]
|
np.ndarray: A reward calculated with a sigmoid function. The stepness and the tipping point can be modified via passed arguments. |
Source code in bofire/data_models/objectives/sigmoid.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
MovingMaximizeSigmoidObjective
Bases: SigmoidObjective
Class for a maximizing sigmoid objective with a moving turning point that depends on so far observed x values.
Attributes:
Name | Type | Description |
---|---|---|
w |
float
|
float between zero and one for weighting the objective when used in a weighting based strategy. |
steepness |
float
|
Steepness of the sigmoid function. Has to be greater than zero. |
tp |
float
|
Relative turning point of the sigmoid function. The actual turning point is calculated by adding the maximum of the observed x values to the relative turning point. |
Source code in bofire/data_models/objectives/sigmoid.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
__call__(x, x_adapt)
The call function returning a sigmoid shaped reward for passed x values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
An array of x values |
required |
x_adapt
|
ndarray
|
An array of x values which are used to update the objective parameters on the fly. |
required |
Returns:
Type | Description |
---|---|
Union[Series, ndarray]
|
np.ndarray: A reward calculated with a sigmoid function. The stepness and the tipping point can be modified via passed arguments. |
Source code in bofire/data_models/objectives/sigmoid.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
get_adjusted_tp(x)
Get the adjusted turning point for the sigmoid function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
An array of x values |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The adjusted turning point for the sigmoid function. |
Source code in bofire/data_models/objectives/sigmoid.py
72 73 74 75 76 77 78 79 80 81 82 |
|
SigmoidObjective
Bases: Objective
, ConstrainedObjective
Base class for all sigmoid shaped objectives
Attributes:
Name | Type | Description |
---|---|---|
w |
float
|
float between zero and one for weighting the objective. |
steepness |
float
|
Steepness of the sigmoid function. Has to be greater than zero. |
tp |
float
|
Turning point of the sigmoid function. |
Source code in bofire/data_models/objectives/sigmoid.py
14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
target
CloseToTargetObjective
Bases: Objective
Optimize towards a target value. It can be used as objective in multiobjective scenarios.
Attributes:
Name | Type | Description |
---|---|---|
w |
float
|
float between zero and one for weighting the objective. |
target_value |
float
|
target value that should be reached. |
exponent |
float
|
the exponent of the expression. |
Source code in bofire/data_models/objectives/target.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
TargetObjective
Bases: Objective
, ConstrainedObjective
Class for objectives for optimizing towards a target value
Attributes:
Name | Type | Description |
---|---|---|
w |
float
|
float between zero and one for weighting the objective. |
target_value |
float
|
target value that should be reached. |
tolerance |
float
|
Tolerance for reaching the target. Has to be greater than zero. |
steepness |
float
|
Steepness of the sigmoid function. Has to be greater than zero. |
Source code in bofire/data_models/objectives/target.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
__call__(x, x_adapt=None)
The call function returning a reward for passed x values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
array
|
An array of x values |
required |
x_adapt
|
Optional[ndarray]
|
An array of x values which are used to update the objective parameters on the fly. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Union[Series, ndarray]
|
np.array: An array of reward values calculated by the product of two sigmoidal shaped functions resulting in a maximum at the target value. |
Source code in bofire/data_models/objectives/target.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|