Functions

This page contains the documentation for all exported functions.

The Main Function

The main function bo!(problem::BossProblem; kwargs...) performs the Bayesian optimization. It augments the dataset (problem.data) and updates the model parameters and/or hyperparameters (problem.params) of the provided BossProblem.

The following diagram showcases the pipeline of the main function bo!.

BOSS Pipeline
BOSS.bo!Function
bo!(problem::BossProblem{Function}; kwargs...)
x = bo!(problem::BossProblem{Missing}; kwargs...)

Run the Bayesian optimization procedure to solve the given optimization problem or give a recommendation for the next evaluation point if problem.f == missing.

Arguments

  • problem::BossProblem: Defines the optimization problem.

Keywords

  • model_fitter::ModelFitter: Defines the algorithm used to estimate model parameters.
  • acq_maximizer::AcquisitionMaximizer: Defines the algorithm used to maximize the acquisition function.
  • term_cond::TermCond: Defines the termination condition.
  • options::BossOptions: Defines miscellaneous settings.

References

BossProblem, ModelFitter, AcquisitionMaximizer, TermCond, BossOptions

Examples

See 'https://soldasim.github.io/BOSS.jl/stable/example/' for example usage.

source

The package can be used in two modes;

The "BO mode" is used if the objective function is defined within the BossProblem. In this mode, BOSS performs the standard Bayesian optimization procedure while querying the objective function for new points.

The "Recommender mode" is used if the objective function is missing. In this mode, BOSS performs a single iteration of the Bayesian optimization procedure and returns a recommendation for the next evaluation point. The user can evaluate the objective function manually, use the method augment_dataset! to add the result to the data, and call bo! again for a new recommendation.

Important Functions

BOSS.estimate_parameters!Function
estimate_parameters!(::BossProblem, ::ModelFitter)

Estimate the model parameters & hyperparameters using the given model_fitter algorithm.

Keywords

  • options::BossOptions: Defines miscellaneous settings.
source
BOSS.maximize_acquisitionFunction
x = maximize_acquisition(::BossProblem, ::AcquisitionMaximizer)

Maximize the given acquisition function via the given acq_maximizer algorithm to find the optimal next evaluation point(s).

Keywords

  • options::BossOptions: Defines miscellaneous settings.
source
BOSS.eval_objective!Function
eval_objective!(::BossProblem, x::AbstractVector{<:Real})

Evaluate the objective function and update the data.

Keywords

  • options::BossOptions: Defines miscellaneous settings.
source
BOSS.augment_dataset!Function
augment_dataset!(::BossProblem, x::AbstractVector{<:Real}, y, others...)
augment_dataset!(::BossProblem, x::AbstractVector{<:Real}, outputs::Any)

Add a new data point to the dataset. The optional others arguments are passed to the data-specific augment_dataset method.

source
BOSS.construct_acquisitionFunction
construct_acquisition(::AcquisitionFunction, ::BossProblem, ::BossOptions) -> (x -> ::Real)

Construct the given AcquisitionFunction for the given BossProblem.

The returned function acq(x::AbstractVector{<:Real}) = val::Real is maximized to select the next evaluation function of blackbox function in each iteration.

This method must be implemented for all subtypes of AcquisitionFunction.

source
BOSS.model_posteriorFunction
model_posterior(::BossProblem) -> ::Union{<:ModelPosterior, <:AbstractVector{<:ModelPosterior}}
model_posterior(::SurrogateModel, ::ModelParams, ::ExperimentData) -> ::ModelPosterior
model_posterior(::SurrogateModel, ::AbstractVector{<:ModelParams}, ::ExperimentData) -> ::AbstractVector{<:ModelPosterior}

Return an instance of ModelPosterior allowing to evaluate the posterior predictive distribution, or a vector of ModelPosteriors in case of multiple sampled model parameters.

See ModelPosterior for the list of available methods.

source
BOSS.model_posterior_sliceFunction
model_posterior_slice(::BossProblem, slice::Int) -> ::Union{<:ModelPosteriorSlice, <:AbstractVector{<:ModelPosteriorSlice}}
model_posterior_slice(::SurrogateModel, ::ModelParams, ::ExperimentData, slice::Int) -> ::ModelPosteriorSlice
model_posterior_slice(::SurrogateModel, ::AbstractVector{<:ModelParams}, ::ExperimentData, slice::Int) -> ::AbstractVector{<:ModelPosteriorSlice}

Return an instance of ModelPosteriorSlice allowing to evaluate the posterior predictive distribution, or a vector of ModelPosteriorSlices in case of multiple sampled model parameters.

See ModelPosteriorSlice for the list of available methods.

source
BOSS.predictive_kindFunction
predictive_kind(::Type{<:SurrogateModel}) -> ::PredictiveKind
predictive_kind(::SurrogateModel) -> ::PredictiveKind
predictive_kind(::AbstractModelPosterior) -> ::PredictiveKind

Trait indicating whether the model's posterior predictive distribution is genuinely Gaussian (GaussianPredictive(), the default — mean/var/mean_and_var are exact) or whether the model additionally provides a more precise weighted-sample representation via predictive_samples (SampledPredictive()).

Should be implemented only on the model's type, i.e. predictive_kind(::Type{<:CustomModel}) = SampledPredictive(). The instance- and posterior-level methods (defined generically here and in ModelPosterior/ModelPosteriorSlice) forward to this type-level method automatically and should not be overridden separately — this keeps the trait's answer for a model, its instances, and its posteriors always in sync by construction.

A model returning SampledPredictive() should implement predictive_samples on its ModelPosterior/ModelPosteriorSlice type(s). A model whose predictive is genuinely Gaussian (e.g. GaussianProcess) should leave this at the default GaussianPredictive() rather than implementing a redundant, strictly noisier sample-based representation.

A wrapper model that reuses another model's predictive distribution unchanged (e.g. TransformedModel) should carry that wrapped model's type as one of its own type parameters and dispatch predictive_kind directly off it — see TransformedModel for the pattern.

source
BOSS.predictive_samplesFunction
predictive_samples(::ModelPosteriorSlice, ::AbstractVector{<:Real}) -> ::Tuple{<:AbstractVector{<:Real}, <:AbstractVector{<:Real}}
predictive_samples(::ModelPosteriorSlice, ::AbstractMatrix{<:Real}) -> ::Tuple{<:AbstractMatrix{<:Real}, <:AbstractMatrix{<:Real}}
predictive_samples(::ModelPosterior, ::AbstractVector{<:Real}) -> ::Tuple{<:AbstractMatrix{<:Real}, <:AbstractMatrix{<:Real}}
predictive_samples(::ModelPosterior, ::AbstractMatrix{<:Real}) -> ::Tuple{<:AbstractArray{<:Real, 3}, <:AbstractArray{<:Real, 3}}

Return a weighted discretization {(yₖ, wₖ)} of the (possibly non-Gaussian) posterior predictive distribution at the given point(s), with sum(ws) == 1. "Samples" may be deterministic quadrature nodes, weighted MC/MCMC draws, or any other weighted-point representation.

Shapes

  • ModelPosteriorSlice, point x: ys, ws are length-K vectors.
  • ModelPosteriorSlice, points X ((x_dim, n)): Ys, Ws are (K, n).
  • ModelPosterior, point x: Ys is (y_dim, K); Ws is (1, K)
  • ModelPosterior, points X: Ys is (y_dim, K, n), Ws is (1, K, n).

Ws's shared weight across dimensions must hold by construction of the sampling scheme (e.g. shared quadrature nodes); it cannot be derived after the fact from differing per-dimension weights.

Only implemented by models with predictive_kind(...) isa SampledPredictive; assumed more precise than mean/var/mean_and_var. Calling this on a GaussianPredictive model throws MethodError.

Implement at exactly one level

Implement this only at ModelPosteriorSlice (independent per-dimension sampling, e.g. WarpedGaussianProcess) or only at ModelPosterior (genuine joint sampling) — never both, and never by bundling one from the other. Bundling independent per-dimension atoms under a shared index induces artificial dependency between dimensions that the model doesn't actually have, giving silently wrong results for any likelihood that isn't separable across dimensions. See posterior.jl for how DefaultModelPosterior/DefaultModelPosteriorSlice handle this.

See also: predictive_kind.

source

Utility Functions

BOSS.x_dimFunction
x_dim(::BossProblem) -> Int

Return the input dimension of the problem.

source
BOSS.y_dimFunction
y_dim(::BossProblem) -> Int

Return the output dimension of the problem.

source
BOSS.cons_dimFunction
cons_dim(::BossProblem) -> Int
cons_dim(::Domain) -> Int

Return the output dimension of the constraint function on the input.

See Domain for more information.

source
BOSS.data_countFunction
data_count(::BossProblem) -> Int

Return the number of datapoints in the dataset.

source
BOSS.is_consistentFunction
is_consistent(::BossProblem) -> Bool

Return true iff the model parameters have been fitted using the current dataset.

source
BOSS.get_fitnessFunction
get_fitness(::AcquisitionFunction) -> (y -> ::Real)

Return the fitness function if the given AcquisitionFunction defines it. Otherwise, throw MethodError.

source
BOSS.get_paramsFunction
get_params(::BossProblem) -> ::Union{::ModelParams, AbstractVector{<:ModelParams}}
get_params(::UniFittedParams) -> ::ModelParams
get_params(::MultiFittedParams) -> ::AbstractVector{<:ModelParams}

Return the fitted ModelParams or a vector of ModelParams samples.

source
BOSS.resultFunction
result(problem) -> (x, y)

Return the best found point (x, y).

The provided BossProblem must contain an AcquisitionFunction, with the get_fitness function defined.

Returns the point (x, y) from the dataset of the given problem such that y satisfies the constraints and fitness(y) is maximized. Returns nothing if the dataset is empty or if no feasible point is present.

Does not check whether x belongs to the domain as no exterior points should be present in the dataset.

source
BOSS.TruncatedMvNormalType
TruncatedMvNormal(μ, Σ, lb, ub)

Defines the truncated multivariate normal distribution with mean μ, covariance matrix Σ, lower bounds lb, and upper bounds ub.

source