input#

Constraints on the input features of a parameter space

Classes

BatchVariance_Constraint(X_space, ind[, tol])

Constraint how much one parameter can vary over a batch of optimized points

Input_Constraint(X_space)

Input constraint for a given parameter space.

Linear_Constraint(X_space[, ind, weights, ...])

Input constraint for a given parameter space.

Nonlinear_Constraint(X_space)

Abstract class for nonlinear constraints

class obsidian.constraints.input.BatchVariance_Constraint(X_space: IParamSpace, ind: int, tol: int | float = 0.01)[source]#

Bases: Nonlinear_Constraint

Constraint how much one parameter can vary over a batch of optimized points

X_space#

The parameter space object.

Type:

ParamSpace

indices#

The indices of the parameters to be constrained. Defaults to [0].

Type:

list[float | int], optional

coeff#

The coefficients for the parameters in the constraint equation. Defaults to [1].

Type:

list[float | int | list], optional

rhs#

The right-hand side value of the constraint equation. Defaults to -1.

Type:

int | float, optional

forward()[source]#

Forward method for the input constraint.

Returns:

A tuple containing the callable function and a boolean

indicating whether the constraint is an intra-point constraint.

Return type:

tuple[callable, bool]

class obsidian.constraints.input.Input_Constraint(X_space: IParamSpace)[source]#

Bases: Constraint

Input constraint for a given parameter space.

Note: Saving and loading input constraints is managed by ParamSpace.

The interface class IParamSpace is used here to avoid circular imports with constraints that depend on ParamSpace, which saves/loads constraints.

class obsidian.constraints.input.Linear_Constraint(X_space: IParamSpace, ind: list[float | int] = [0], weights: list[float | int] = [1], rhs: int | float = -1, equality: bool = False)[source]#

Bases: Input_Constraint

Input constraint for a given parameter space.

Note: SUM(LHS) <= RHS equivalent to -SUM(LHS) >= -RHS

Linear constraints must return:

tuple = (indices = Tensor, coefficients = Tensor, rhs = float) where sum_i(X[indices[i]] * coefficients[i]) = rhs (equality) or >= rhs (inequality)

X_space#

The parameter space object.

Type:

ParamSpace

ind#

The indices of the parameters to be constrained. Defaults to [0].

Type:

list[float | int], optional

weights#

The coefficients for the parameters in the constraint equation. Defaults to [1].

Type:

list[float | int | list], optional

rhs#

The right-hand side value of the constraint equation. Defaults to -1.

Type:

int | float, optional

equality#

Whether the constraint is an equality (=) or inequality (>=) constraint. Defaults to False for inequality constraint.

Type:

bool, optional

forward() tuple[Tensor, Tensor, Tensor][source]#

Forward method for the input constraint.

Forms the linear constraint in the tuple that can be handled by BoTorch optimizer.

Returns:

A tuple containing the indices, coefficients,

and right-hand side value of the constraint in the encoded space.

Return type:

tuple[Tensor, Tensor, Tensor]

class obsidian.constraints.input.Nonlinear_Constraint(X_space: IParamSpace)[source]#

Bases: Input_Constraint

Abstract class for nonlinear constraints

Nonlinear inequality constraints must return:

tuple = (constraint(x) = callable, intra-point = bool)

where:

Intra point: callable takes X in (d) and return scalar Intra point: when q = 1, or when applying the same constraint to each

candidate in the batch

Inter point: callable takes X in (q x d) and returns scalar Inter point: When q > 1 and the constraints are applied to an entire

batch of candidates

Use 1-d tensor of indices for intra point constraint Use 2-d tensor of indices for inter point constraint where indices[i] = (k_i, l_i, …)

abstract forward() tuple[callable, bool][source]#

Forward method for the input constraint.

Returns:

A tuple containing the callable function and a boolean

indicating whether the constraint is an intra-point constraint.

Return type:

tuple[callable, bool]