Skip to content

Commit

Permalink
Re-introduce Lhs optim parallel processing (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
relf authored Dec 20, 2023
1 parent c96d6d5 commit e3be206
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions doe/src/lhs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,18 @@ mod tests {
let sample2 = lhs.sample(5);
assert_abs_diff_ne!(sample1, sample2);
}

#[test]
fn test_lhs_clone_different() {
let xlimits = array![[-1., 1.]];
let rng = Xoshiro256Plus::seed_from_u64(42);
let lhs = Lhs::new(&xlimits)
.kind(LhsKind::Classic)
.with_rng(rng.clone());
let lhs1 = lhs.clone();
let s1 = lhs1.sample(10);
let lhs2 = lhs.clone();
let s2 = lhs2.sample(10);
assert_abs_diff_ne!(s1, s2);
}
}
3 changes: 2 additions & 1 deletion ego/src/lhs_optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use egobox_doe::{Lhs, LhsKind, SamplingMethod};
use ndarray::{Array1, Array2, Axis, Zip};
use ndarray_rand::rand::{Rng, SeedableRng};
use rand_xoshiro::Xoshiro256Plus;
//use rayon::prelude::*;
use rayon::prelude::*;

#[cfg(not(feature = "blas"))]
use linfa_linalg::norm::*;
Expand Down Expand Up @@ -150,6 +150,7 @@ impl<'a, R: Rng + Clone + Sync + Send> LhsOptimizer<'a, R> {

// Make n_start optim
let x_optims = (0..self.n_start)
.into_par_iter()
.map(|_| self.find_lhs_min(lhs.clone()))
.collect::<Vec<_>>();

Expand Down

0 comments on commit e3be206

Please sign in to comment.