pub struct BayesianOptimizer { /* private fields */ }Expand description
The Bayesian optimizer.
Supports sequential single-objective, batch, multi-objective (ParEGO), and constrained optimization.
Implementations§
Source§impl BayesianOptimizer
impl BayesianOptimizer
Sourcepub fn new(
bounds: Vec<(f64, f64)>,
config: BayesianOptimizerConfig,
) -> OptimizeResult<Self>
pub fn new( bounds: Vec<(f64, f64)>, config: BayesianOptimizerConfig, ) -> OptimizeResult<Self>
Create a new Bayesian optimizer.
§Arguments
bounds- Search bounds for each dimension:[(lo, hi), ...]config- Optimizer configuration
Sourcepub fn with_kernel(
bounds: Vec<(f64, f64)>,
kernel: Box<dyn SurrogateKernel>,
config: BayesianOptimizerConfig,
) -> OptimizeResult<Self>
pub fn with_kernel( bounds: Vec<(f64, f64)>, kernel: Box<dyn SurrogateKernel>, config: BayesianOptimizerConfig, ) -> OptimizeResult<Self>
Create a new optimizer with a custom kernel.
Sourcepub fn add_constraint<F>(&mut self, name: &str, func: F)
pub fn add_constraint<F>(&mut self, name: &str, func: F)
Add a constraint: satisfied when g(x) <= 0.
Sourcepub fn warm_start(
&mut self,
x_data: &Array2<f64>,
y_data: &Array1<f64>,
) -> OptimizeResult<()>
pub fn warm_start( &mut self, x_data: &Array2<f64>, y_data: &Array1<f64>, ) -> OptimizeResult<()>
Warm-start from previous evaluations.
Sourcepub fn optimize<F>(
&mut self,
objective: F,
n_iter: usize,
) -> OptimizeResult<BayesianOptResult>
pub fn optimize<F>( &mut self, objective: F, n_iter: usize, ) -> OptimizeResult<BayesianOptResult>
Run the sequential optimization loop.
§Arguments
objective- Function to minimize.n_iter- Number of iterations (function evaluations after initial design).
Sourcepub fn optimize_batch<F>(
&mut self,
objective: F,
n_rounds: usize,
batch_size: usize,
) -> OptimizeResult<BayesianOptResult>
pub fn optimize_batch<F>( &mut self, objective: F, n_rounds: usize, batch_size: usize, ) -> OptimizeResult<BayesianOptResult>
Run batch optimization, evaluating batch_size points in parallel per round.
Uses the Kriging Believer strategy: after selecting a candidate, the GP is updated with a fantasised observation at the predicted mean.
Sourcepub fn optimize_multi_objective<F>(
&mut self,
objectives: &[F],
n_iter: usize,
) -> OptimizeResult<BayesianOptResult>
pub fn optimize_multi_objective<F>( &mut self, objectives: &[F], n_iter: usize, ) -> OptimizeResult<BayesianOptResult>
Multi-objective optimization via ParEGO scalarization.
Uses random weight vectors to scalarise the objectives into a single augmented Chebyshev function, then runs standard BO on the scalarization.
§Arguments
objectives- Vector of objective functions to minimize.n_iter- Number of sequential iterations.
Sourcepub fn ask(&mut self) -> OptimizeResult<Array1<f64>>
pub fn ask(&mut self) -> OptimizeResult<Array1<f64>>
Get the ask interface: suggest the next point to evaluate.
Sourcepub fn tell(&mut self, x: Array1<f64>, y: f64) -> OptimizeResult<()>
pub fn tell(&mut self, x: Array1<f64>, y: f64) -> OptimizeResult<()>
Tell interface: update with an observation.
Sourcepub fn best(&self) -> Option<&Observation>
pub fn best(&self) -> Option<&Observation>
Get the current best observation.
Sourcepub fn observations(&self) -> &[Observation]
pub fn observations(&self) -> &[Observation]
Get all observations.
Sourcepub fn n_observations(&self) -> usize
pub fn n_observations(&self) -> usize
Number of observations.
Sourcepub fn surrogate(&self) -> &GpSurrogate
pub fn surrogate(&self) -> &GpSurrogate
Get reference to the GP surrogate.
Auto Trait Implementations§
impl Freeze for BayesianOptimizer
impl !RefUnwindSafe for BayesianOptimizer
impl Send for BayesianOptimizer
impl Sync for BayesianOptimizer
impl Unpin for BayesianOptimizer
impl UnsafeUnpin for BayesianOptimizer
impl !UnwindSafe for BayesianOptimizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.