-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better Egor solver state handling (#168)
* Add solver final state in optim result * Rename random_seed in seed * Add Egor benchmark * Implement find best result using best_index state Instead of recomputing from the whole history dataset, we just compare new points with current best * Remove dead code (thanks clippy) * Make clippy happy * Remove brittle test
- Loading branch information
Showing
12 changed files
with
235 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use egobox_ego::{EgorBuilder, InfillStrategy}; | ||
use egobox_moe::{CorrelationSpec, RegressionSpec}; | ||
use ndarray::{array, Array2, ArrayView2, Zip}; | ||
|
||
/// Ackley test function: min f(x)=0 at x=(0, 0, 0) | ||
fn ackley(x: &ArrayView2<f64>) -> Array2<f64> { | ||
let mut y: Array2<f64> = Array2::zeros((x.nrows(), 1)); | ||
Zip::from(y.rows_mut()) | ||
.and(x.rows()) | ||
.par_for_each(|mut yi, xi| yi.assign(&array![argmin_testfunctions::ackley(&xi.to_vec(),)])); | ||
y | ||
} | ||
|
||
fn criterion_ego(c: &mut Criterion) { | ||
let xlimits = array![[-32.768, 32.768], [-32.768, 32.768], [-32.768, 32.768]]; | ||
let mut group = c.benchmark_group("ego"); | ||
group.bench_function("ego ackley", |b| { | ||
b.iter(|| { | ||
black_box( | ||
EgorBuilder::optimize(ackley) | ||
.configure(|config| { | ||
config | ||
.regression_spec(RegressionSpec::CONSTANT) | ||
.correlation_spec(CorrelationSpec::ABSOLUTEEXPONENTIAL) | ||
.infill_strategy(InfillStrategy::WB2S) | ||
.max_iters(10) | ||
.target(5e-1) | ||
.seed(42) | ||
}) | ||
.min_within(&xlimits) | ||
.run() | ||
.expect("Minimize failure"), | ||
) | ||
}); | ||
}); | ||
|
||
group.finish(); | ||
} | ||
|
||
criterion_group!(benches, criterion_ego); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.