Skip to content

Commit fb33b62

Browse files
committed
Adjust constraint tolerance
1 parent a18516b commit fb33b62

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

ego/examples/mopta08.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ fn main() -> anyhow::Result<()> {
265265
.configure(|config| {
266266
config
267267
.n_cstr(N_CSTR)
268-
.cstr_tol(&cstr_tol)
268+
.cstr_tol(cstr_tol.clone())
269269
.n_clusters(1)
270270
.n_start(50)
271271
.n_doe(n_doe)

ego/src/egor.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,20 @@ mod tests {
412412
.with_rng(Xoshiro256Plus::seed_from_u64(42))
413413
.sample(3);
414414
let res = EgorBuilder::optimize(f_g24)
415-
.configure(|config| config.n_cstr(2).doe(&doe).max_iters(20).random_seed(42))
415+
.configure(|config| {
416+
config
417+
.n_cstr(2)
418+
.doe(&doe)
419+
.max_iters(20)
420+
.cstr_tol(array![2e-6, 1e-6])
421+
.random_seed(42)
422+
})
416423
.min_within(&xlimits)
417424
.run()
418425
.expect("Minimize failure");
419426
println!("G24 optim result = {res:?}");
420427
let expected = array![2.3295, 3.1785];
421-
assert_abs_diff_eq!(expected, res.x_opt, epsilon = 5e-2);
428+
assert_abs_diff_eq!(expected, res.x_opt, epsilon = 2e-2);
422429
}
423430

424431
#[test]
@@ -434,7 +441,7 @@ mod tests {
434441
.regression_spec(RegressionSpec::ALL)
435442
.correlation_spec(CorrelationSpec::ALL)
436443
.n_cstr(2)
437-
.cstr_tol(&array![2e-6, 2e-6])
444+
.cstr_tol(array![2e-6, 2e-6])
438445
.q_points(2)
439446
.qei_strategy(QEiStrategy::KrigingBeliever)
440447
.doe(&doe)

ego/src/egor_config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ impl EgorConfig {
125125
}
126126

127127
/// Sets the tolerance on constraints violation (`cstr < tol`)
128-
pub fn cstr_tol(mut self, tol: &Array1<f64>) -> Self {
129-
self.cstr_tol = Some(tol.to_owned());
128+
pub fn cstr_tol(mut self, tol: Array1<f64>) -> Self {
129+
self.cstr_tol = Some(tol);
130130
self
131131
}
132132

src/egor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ impl Egor {
433433
.max_iters(max_iters.unwrap_or(1))
434434
.n_start(self.n_start)
435435
.n_doe(self.n_doe)
436-
.cstr_tol(&cstr_tol)
436+
.cstr_tol(cstr_tol)
437437
.regression_spec(egobox_moe::RegressionSpec::from_bits(self.regression_spec.0).unwrap())
438438
.correlation_spec(
439439
egobox_moe::CorrelationSpec::from_bits(self.correlation_spec.0).unwrap(),

0 commit comments

Comments
 (0)