custom#

Custom objective function formulations

Classes

Bounded_Target(bounds, targets[, tau])

Represents a bounded target objective for multi-output and single-output acquisition objectives

Divide_Objective(ind_num, ind_denom[, ...])

Objective function that computes the weighted quotient of other objectives

Feature_Objective(X_space, ind, coeff)

Creates an objective function which creates a new outcome as a linear combination of input features.

Identity_Objective([mo])

Dummy multi-output objective function that simply returns the input Y.

Index_Objective([ind])

Creates an objective function that returns the single-objective output from a multi-output model, at the specified index.

Product_Objective(ind[, weights, const, new_dim])

Objective function that computes the weighted products of other objectives

Utopian_Distance(utopian, targets)

A custom objective for calculating the distance between an output response and a most-desirable, ideal/utopian point.

class obsidian.objectives.custom.Bounded_Target(bounds: list[tuple[float, float] | None], targets: Target | list[Target], tau: float = 0.001)[source]#

Bases: Objective

Represents a bounded target objective for multi-output and single-output acquisition objectives

Parameters:
  • bounds (list[tuple[float, float] | None]) – The bounds for each target. If a bound is None, it is ignored.

  • targets (Target | list[Target]) – The target or list of targets.

  • tau (float, optional) – The temperature parameter for the sigmoid function. Defaults to 1e-3.

lb#

The lower bounds for the targets.

Type:

torch.Tensor

ub#

The upper bounds for the targets.

Type:

torch.Tensor

tau#

The temperature parameter for the sigmoid function.

Type:

torch.Tensor

ind#

The indices of the non-None bounds.

Type:

torch.Tensor

forward(samples: Tensor, X: Tensor | None = None) Tensor[source]#

Evaluate the objective function on the candidate set samples, X

classmethod load_state(obj_dict: dict)[source]#

Loads the objective from a state dictionary

save_state() dict[source]#

Saves the objective to a state dictionary

class obsidian.objectives.custom.Divide_Objective(ind_num: int, ind_denom: int, w_num: float | int = 1, w_denom: float | int = 1, const: float | int = 0, new_dim: bool = True)[source]#

Bases: Objective

Objective function that computes the weighted quotient of other objectives

(w_num * samples[…, ind_num])/(w_denom * samples[…, ind_denom]) + const

Parameters:
  • ind_num (int) – The index of the objective to be used in the numerator

  • w_num (float | int, optional) – The weight corresponding to numerator objective. Defaults to 1.

  • ind_denom (int) – The index of the objective to be used in the denominator

  • w_denom (float | int, optional) – The weight corresponding to denominator objective. Defaults to 1.

  • const (float | int) – A constant value that can be added to the quotient

  • new_dim (bool, optional) – Whether to create a new objective dimension from this quotient. Default is False. Setting to True will make this the only output objective.

forward(samples: Tensor, X: Tensor | None = None) Tensor[source]#

Evaluate the objective function on the candidate set samples, X

class obsidian.objectives.custom.Feature_Objective(X_space: ParamSpace, ind: tuple[int], coeff: list[float | int])[source]#

Bases: Objective

Creates an objective function which creates a new outcome as a linear combination of input features.

Always a multi-output objective.

Parameters:
  • X_space (ParamSpace) – The parameter space.

  • ind (tuple[int]) – The indices of the parameters in the real space to be used as features.

  • coeff (list[float | int], optional) – The coefficients corresponding to each feature. Defaults to [0].

Raises:
  • ValueError – If the length of ind and coeff are not the same.

  • TypeError – If the indices for input objectives are not for continuous parameters.

forward(samples: Tensor, X: Tensor) Tensor[source]#

Evaluate the objective function on the candidate set samples, X

classmethod load_state(obj_dict: dict)[source]#

Loads the objective from a state dictionary

save_state() dict[source]#

Saves the objective to a state dictionary

class obsidian.objectives.custom.Identity_Objective(mo: bool = False)[source]#

Bases: Objective

Dummy multi-output objective function that simply returns the input Y.

forward(samples: Tensor, X: Tensor | None = None) Tensor[source]#

Evaluate the objective function on the candidate set samples, X

class obsidian.objectives.custom.Index_Objective(ind: int | tuple[int] = 0)[source]#

Bases: Objective

Creates an objective function that returns the single-objective output from a multi-output model, at the specified index.

Single-objective when index is int; multi-objective if tuple.

Parameters:

ind (int | tuple[int]) – The index of the value to be returned.

forward(samples: Tensor, X: Tensor | None = None) Tensor[source]#

Evaluate the objective function on the candidate set samples, X

class obsidian.objectives.custom.Product_Objective(ind: tuple[int], weights: list[float | int] | None = None, const: float | int = 0, new_dim: bool = True)[source]#

Bases: Objective

Objective function that computes the weighted products of other objectives

Parameters:
  • ind (tuple[int]) – The indices of objectives to be used in a product

  • weights (list[float | int], optional) – The weights corresponding to indexed objectives. Defaults to (1,)*len(ind).

  • const (float | int) – A constant value that can be added to the product

  • new_dim (bool, optional) – Whether to create a new objective dimension from this product. Default is False. Setting to True will make this the only output objective.

forward(samples: Tensor, X: Tensor | None = None) Tensor[source]#

Evaluate the objective function on the candidate set samples, X

class obsidian.objectives.custom.Utopian_Distance(utopian: list[float | int], targets: Target | list[Target])[source]#

Bases: Objective

A custom objective for calculating the distance between an output response and a most-desirable, ideal/utopian point.

Parameters:
  • utopian (tuple[float | int]) – A list of values representing the utopian point.

  • targets (Target | list[Target]) – A single Target object or a list of Target objects.

u_t#

The utopian coordinates in transformed space

Type:

Tensor

Raises:
  • TypeError – If the input is not a list of Target objects.

  • ValueError – If the length of the utopian point and targets are not the same.

forward(samples: Tensor, X: Tensor | None = None) Tensor[source]#

Evaluate the objective function on the candidate set samples, X

classmethod load_state(obj_dict: dict)[source]#

Loads the objective from a state dictionary

save_state() dict[source]#

Saves the objective to a state dictionary