pub fn optimize<F>(
objective: F,
bounds: &[(f64, f64)],
n_iter: usize,
config: Option<BayesianOptimizerConfig>,
) -> OptimizeResult<BayesianOptResult>Expand description
Run Bayesian optimization on a function.
This is a high-level convenience function that creates a BayesianOptimizer,
runs the optimization, and returns the result.
§Arguments
objective- Function to minimize:f(x) -> f64bounds- Search bounds:[(lo, hi), ...]n_iter- Number of sequential iterations (after initial design)config- Optional optimizer configuration
§Example
use scirs2_optimize::bayesian::optimize;
use scirs2_core::ndarray::ArrayView1;
let result = optimize(
|x: &ArrayView1<f64>| x[0].powi(2) + x[1].powi(2),
&[(-5.0, 5.0), (-5.0, 5.0)],
20,
None,
).expect("optimization failed");
assert!(result.f_best < 1.0);