Skip to content

Commit

Permalink
Adjust constraint tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
relf committed Feb 19, 2024
1 parent a18516b commit fb33b62
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ego/examples/mopta08.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ fn main() -> anyhow::Result<()> {
.configure(|config| {
config
.n_cstr(N_CSTR)
.cstr_tol(&cstr_tol)
.cstr_tol(cstr_tol.clone())
.n_clusters(1)
.n_start(50)
.n_doe(n_doe)
Expand Down
13 changes: 10 additions & 3 deletions ego/src/egor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,20 @@ mod tests {
.with_rng(Xoshiro256Plus::seed_from_u64(42))
.sample(3);
let res = EgorBuilder::optimize(f_g24)
.configure(|config| config.n_cstr(2).doe(&doe).max_iters(20).random_seed(42))
.configure(|config| {
config
.n_cstr(2)
.doe(&doe)
.max_iters(20)
.cstr_tol(array![2e-6, 1e-6])
.random_seed(42)
})
.min_within(&xlimits)
.run()
.expect("Minimize failure");
println!("G24 optim result = {res:?}");
let expected = array![2.3295, 3.1785];
assert_abs_diff_eq!(expected, res.x_opt, epsilon = 5e-2);
assert_abs_diff_eq!(expected, res.x_opt, epsilon = 2e-2);
}

#[test]
Expand All @@ -434,7 +441,7 @@ mod tests {
.regression_spec(RegressionSpec::ALL)
.correlation_spec(CorrelationSpec::ALL)
.n_cstr(2)
.cstr_tol(&array![2e-6, 2e-6])
.cstr_tol(array![2e-6, 2e-6])
.q_points(2)
.qei_strategy(QEiStrategy::KrigingBeliever)
.doe(&doe)
Expand Down
4 changes: 2 additions & 2 deletions ego/src/egor_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ impl EgorConfig {
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/egor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ impl Egor {
.max_iters(max_iters.unwrap_or(1))
.n_start(self.n_start)
.n_doe(self.n_doe)
.cstr_tol(&cstr_tol)
.cstr_tol(cstr_tol)
.regression_spec(egobox_moe::RegressionSpec::from_bits(self.regression_spec.0).unwrap())
.correlation_spec(
egobox_moe::CorrelationSpec::from_bits(self.correlation_spec.0).unwrap(),
Expand Down

0 comments on commit fb33b62

Please sign in to comment.