Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d88280c152 | |||
| 0e8fc82201 |
+2
-2
@@ -3,7 +3,7 @@ members = ["optimizer-derive"]
|
|||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "optimizer"
|
name = "optimizer"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.88"
|
rust-version = "1.88"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
@@ -16,7 +16,7 @@ categories = ["algorithm", "science", "data-structures"]
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rand = "0.9"
|
rand = "0.10"
|
||||||
thiserror = "2"
|
thiserror = "2"
|
||||||
parking_lot = "0.12"
|
parking_lot = "0.12"
|
||||||
tokio = { version = "1", features = ["sync", "rt-multi-thread"], optional = true }
|
tokio = { version = "1", features = ["sync", "rt-multi-thread"], optional = true }
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
//! parameter independently, the multivariate KDE models the joint distribution
|
//! parameter independently, the multivariate KDE models the joint distribution
|
||||||
//! to better capture correlations between parameters.
|
//! to better capture correlations between parameters.
|
||||||
|
|
||||||
use rand::Rng;
|
use rand::{Rng, RngExt};
|
||||||
|
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//! This module provides a Gaussian kernel density estimator used by the TPE
|
//! This module provides a Gaussian kernel density estimator used by the TPE
|
||||||
//! sampler to model probability distributions over good and bad trial regions.
|
//! sampler to model probability distributions over good and bad trial regions.
|
||||||
|
|
||||||
use rand::Rng;
|
use rand::{Rng, RngExt};
|
||||||
|
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use rand::rngs::StdRng;
|
use rand::rngs::StdRng;
|
||||||
use rand::{Rng, SeedableRng};
|
use rand::{RngExt, SeedableRng};
|
||||||
|
|
||||||
use crate::distribution::Distribution;
|
use crate::distribution::Distribution;
|
||||||
use crate::param::ParamValue;
|
use crate::param::ParamValue;
|
||||||
@@ -34,7 +34,7 @@ impl RandomSampler {
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
rng: Mutex::new(StdRng::from_os_rng()),
|
rng: Mutex::new(rand::make_rng()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ use std::collections::HashMap;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use rand::SeedableRng;
|
|
||||||
use rand::rngs::StdRng;
|
use rand::rngs::StdRng;
|
||||||
|
use rand::{RngExt, SeedableRng};
|
||||||
|
|
||||||
use super::{FixedGamma, GammaStrategy};
|
use super::{FixedGamma, GammaStrategy};
|
||||||
use crate::distribution::Distribution;
|
use crate::distribution::Distribution;
|
||||||
@@ -219,7 +219,7 @@ impl MultivariateTpeSampler {
|
|||||||
n_ei_candidates: 24,
|
n_ei_candidates: 24,
|
||||||
group: false,
|
group: false,
|
||||||
constant_liar: ConstantLiarStrategy::None,
|
constant_liar: ConstantLiarStrategy::None,
|
||||||
rng: Mutex::new(StdRng::from_os_rng()),
|
rng: Mutex::new(rand::make_rng()),
|
||||||
joint_sample_cache: Mutex::new(None),
|
joint_sample_cache: Mutex::new(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -782,8 +782,6 @@ impl MultivariateTpeSampler {
|
|||||||
distribution: &Distribution,
|
distribution: &Distribution,
|
||||||
rng: &mut rand::rngs::StdRng,
|
rng: &mut rand::rngs::StdRng,
|
||||||
) -> ParamValue {
|
) -> ParamValue {
|
||||||
use rand::Rng;
|
|
||||||
|
|
||||||
match distribution {
|
match distribution {
|
||||||
Distribution::Float(d) => {
|
Distribution::Float(d) => {
|
||||||
let value = if d.log_scale {
|
let value = if d.log_scale {
|
||||||
@@ -1374,8 +1372,6 @@ impl MultivariateTpeSampler {
|
|||||||
bad_values: Vec<f64>,
|
bad_values: Vec<f64>,
|
||||||
rng: &mut StdRng,
|
rng: &mut StdRng,
|
||||||
) -> f64 {
|
) -> f64 {
|
||||||
use rand::Rng;
|
|
||||||
|
|
||||||
use crate::kde::KernelDensityEstimator;
|
use crate::kde::KernelDensityEstimator;
|
||||||
|
|
||||||
// Transform to internal space (log space if needed)
|
// Transform to internal space (log space if needed)
|
||||||
@@ -1568,8 +1564,6 @@ impl MultivariateTpeSampler {
|
|||||||
bad_indices: &[usize],
|
bad_indices: &[usize],
|
||||||
rng: &mut rand::rngs::StdRng,
|
rng: &mut rand::rngs::StdRng,
|
||||||
) -> usize {
|
) -> usize {
|
||||||
use rand::Rng;
|
|
||||||
|
|
||||||
// Count occurrences in good and bad groups
|
// Count occurrences in good and bad groups
|
||||||
let mut good_counts = vec![0usize; n_choices];
|
let mut good_counts = vec![0usize; n_choices];
|
||||||
let mut bad_counts = vec![0usize; n_choices];
|
let mut bad_counts = vec![0usize; n_choices];
|
||||||
@@ -2076,7 +2070,7 @@ impl MultivariateTpeSamplerBuilder {
|
|||||||
|
|
||||||
let rng = match self.seed {
|
let rng = match self.seed {
|
||||||
Some(s) => StdRng::seed_from_u64(s),
|
Some(s) => StdRng::seed_from_u64(s),
|
||||||
None => StdRng::from_os_rng(),
|
None => rand::make_rng(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(MultivariateTpeSampler {
|
Ok(MultivariateTpeSampler {
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use rand::rngs::StdRng;
|
use rand::rngs::StdRng;
|
||||||
use rand::{Rng, SeedableRng};
|
use rand::{RngExt, SeedableRng};
|
||||||
|
|
||||||
use crate::distribution::Distribution;
|
use crate::distribution::Distribution;
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
@@ -149,7 +149,7 @@ impl TpeSampler {
|
|||||||
n_startup_trials: 10,
|
n_startup_trials: 10,
|
||||||
n_ei_candidates: 24,
|
n_ei_candidates: 24,
|
||||||
kde_bandwidth: None,
|
kde_bandwidth: None,
|
||||||
rng: Mutex::new(StdRng::from_os_rng()),
|
rng: Mutex::new(rand::make_rng()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ impl TpeSampler {
|
|||||||
|
|
||||||
let rng = match seed {
|
let rng = match seed {
|
||||||
Some(s) => StdRng::seed_from_u64(s),
|
Some(s) => StdRng::seed_from_u64(s),
|
||||||
None => StdRng::from_os_rng(),
|
None => rand::make_rng(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
@@ -857,7 +857,7 @@ impl TpeSamplerBuilder {
|
|||||||
|
|
||||||
let rng = match self.seed {
|
let rng = match self.seed {
|
||||||
Some(s) => StdRng::seed_from_u64(s),
|
Some(s) => StdRng::seed_from_u64(s),
|
||||||
None => StdRng::from_os_rng(),
|
None => rand::make_rng(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(TpeSampler {
|
Ok(TpeSampler {
|
||||||
|
|||||||
Reference in New Issue
Block a user