jijzepttools.blackbox_optimization.surrogate_model.bocs_surrogate_model#

Classes#

BOCSParams

Parameters for BOCS (Bayesian Optimization of Combinatorial Structures) surrogate model.

BOCSSurrogateModel

BOCS (Bayesian Optimization of Combinatorial Structures) surrogate model.

Module Contents#

class BOCSParams#

Bases: jijzepttools.blackbox_optimization.surrogate_model.interface.SurrogateModelParams

Parameters for BOCS (Bayesian Optimization of Combinatorial Structures) surrogate model.

random_seed#

Random seed for reproducibility.

Type:

int, optional

draws#
Number of MCMC samples to draw.

drawed samples are used for the mean of coefficients for the optimization.

Type:

int, default=10

tune#

Number of burn-in iterations.

Type:

int, default=100

warm_start#

Whether to continue from the previous Gibbs chain.

Type:

bool, default=False

random_seed: int | None = None#
draws: int = 10#
tune: int = 100#
warm_start: bool = False#
class BOCSSurrogateModel(params: BOCSParams | None = None)#

Bases: jijzepttools.blackbox_optimization.surrogate_model.interface.SurrogateModel

BOCS (Bayesian Optimization of Combinatorial Structures) surrogate model.

This model uses sparse Bayesian linear regression on quadratic features to approximate the objective function. It automatically generates quadratic interaction terms and applies Bayesian regularization.

Parameters:

params (BOCSParams, optional) – Parameters for the model. If None, default parameters are used.

sblr#
draws = 10#
tune = 100#
n_features: int | None = None#
triu_indices: numpy.ndarray | None = None#
fit(x: numpy.ndarray, y: numpy.ndarray) None#

Fit the BOCS model to the data.

This involves: 1. Generating quadratic interaction terms 2. Fitting sparse Bayesian linear regression

Parameters:
  • x (np.ndarray, shape (n_samples, n_features)) – Input features.

  • y (np.ndarray, shape (n_samples,)) – Target values.

predict(x: numpy.ndarray) numpy.ndarray#

Predict target values using the fitted BOCS model.

This generates quadratic interaction terms for the input features and uses the fitted model to make predictions.

Parameters:

x (np.ndarray, shape (n_samples, n_features)) – Input features.

Returns:

Predicted target values.

Return type:

np.ndarray, shape (n_samples,)

surrogate_to_ommx_objective(decision_variables: list[ommx.v1.DecisionVariable])#

Create OMMX expression for the fitted BOCS model.

Notes: - The order of the decision variables is the same as the order of the features.

Parameters:

decision_variables (list[ommx.v1.DecisionVariable]) – Decision variables from OMMX instance.