Skip to content

Commit 1ee73df

Browse files
committed
Rename n_iter in max_iters
1 parent 5f9b401 commit 1ee73df

File tree

9 files changed

+41
-41
lines changed

9 files changed

+41
-41
lines changed

doe/src/lhs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ impl<F: Float, R: Rng + Clone> Lhs<F, R> {
271271
lhs.mapv(F::cast)
272272
}
273273

274-
fn _maximin_lhs(&self, ns: usize, centered: bool, n_iter: usize) -> Array2<F> {
274+
fn _maximin_lhs(&self, ns: usize, centered: bool, max_iters: usize) -> Array2<F> {
275275
let mut max_dist = F::zero();
276276
let mut lhs = self._classic_lhs(ns);
277-
for _ in 0..n_iter {
277+
for _ in 0..max_iters {
278278
if centered {
279279
lhs = self._centered_lhs(ns);
280280
} else {

ego/examples/ackley.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
.regression_spec(RegressionSpec::CONSTANT)
2020
.correlation_spec(CorrelationSpec::ABSOLUTEEXPONENTIAL)
2121
.infill_strategy(InfillStrategy::WB2S)
22-
.n_iter(200)
22+
.max_iters(200)
2323
.target(5e-1)
2424
})
2525
.min_within(&xlimits)

ego/examples/mopta08.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ fn main() -> anyhow::Result<()> {
253253
let dim = args.dim;
254254
let outdir = args.outdir;
255255
let n_doe = 2 * dim;
256-
let n_iter = 2 * dim;
256+
let max_iters = 2 * dim;
257257
const N_CSTR: usize = 68;
258258
let cstr_tol = Array1::from_elem(N_CSTR, 1e-4);
259259
let kpls_dim = 3;
@@ -269,7 +269,7 @@ fn main() -> anyhow::Result<()> {
269269
.n_clusters(1)
270270
.n_start(50)
271271
.n_doe(n_doe)
272-
.n_iter(n_iter)
272+
.max_iters(max_iters)
273273
.regression_spec(RegressionSpec::CONSTANT)
274274
.correlation_spec(CorrelationSpec::SQUAREDEXPONENTIAL)
275275
.infill_optimizer(InfillOptimizer::Slsqp)

ego/examples/rosenbrock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn rosenbrock(x: &ArrayView2<f64>) -> Array2<f64> {
1919
fn main() {
2020
let xlimits = array![[-2., 2.], [-2., 2.]];
2121
let res = EgorBuilder::optimize(rosenbrock)
22-
.configure(|config| config.n_iter(100).target(1e-2))
22+
.configure(|config| config.max_iters(100).target(1e-2))
2323
.min_within(&xlimits)
2424
.run()
2525
.expect("Minimize failure");

ego/src/egor.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
//! .infill_strategy(InfillStrategy::EI)
2525
//! .n_doe(10)
2626
//! .target(1e-1)
27-
//! .n_iter(30))
27+
//! .max_iters(30))
2828
//! .min_within(&xlimits)
2929
//! .run()
3030
//! .expect("Rosenbrock minimization");
@@ -81,7 +81,7 @@
8181
//! .infill_strategy(InfillStrategy::EI)
8282
//! .infill_optimizer(InfillOptimizer::Cobyla)
8383
//! .doe(&doe)
84-
//! .n_iter(40)
84+
//! .max_iters(40)
8585
//! .target(-5.5080))
8686
//! .min_within(&xlimits)
8787
//! .run()
@@ -262,7 +262,7 @@ mod tests {
262262
cfg.infill_strategy(InfillStrategy::EI)
263263
.regression_spec(RegressionSpec::QUADRATIC)
264264
.correlation_spec(CorrelationSpec::ALL)
265-
.n_iter(30)
265+
.max_iters(30)
266266
.doe(&initial_doe)
267267
.target(-15.1)
268268
.outdir("target/tests")
@@ -282,7 +282,7 @@ mod tests {
282282
let res = EgorBuilder::optimize(xsinx)
283283
.configure(|config| {
284284
config
285-
.n_iter(20)
285+
.max_iters(20)
286286
.regression_spec(RegressionSpec::ALL)
287287
.correlation_spec(CorrelationSpec::ALL)
288288
})
@@ -297,7 +297,7 @@ mod tests {
297297
#[serial]
298298
fn test_xsinx_auto_clustering_egor_builder() {
299299
let res = EgorBuilder::optimize(xsinx)
300-
.configure(|config| config.n_clusters(0).n_iter(20))
300+
.configure(|config| config.n_clusters(0).max_iters(20))
301301
.min_within(&array![[0.0, 25.0]])
302302
.run()
303303
.expect("Egor with auto clustering should minimize xsinx");
@@ -313,7 +313,7 @@ mod tests {
313313
let res = EgorBuilder::optimize(xsinx)
314314
.configure(|config| {
315315
config
316-
.n_iter(15)
316+
.max_iters(15)
317317
.doe(&doe)
318318
.outdir("target/tests")
319319
.random_seed(42)
@@ -327,7 +327,7 @@ mod tests {
327327
let res = EgorBuilder::optimize(xsinx)
328328
.configure(|config| {
329329
config
330-
.n_iter(5)
330+
.max_iters(5)
331331
.outdir("target/tests")
332332
.hot_start(true)
333333
.random_seed(42)
@@ -359,7 +359,7 @@ mod tests {
359359
.configure(|config| {
360360
config
361361
.doe(&doe)
362-
.n_iter(100)
362+
.max_iters(100)
363363
.regression_spec(RegressionSpec::ALL)
364364
.correlation_spec(CorrelationSpec::ALL)
365365
.target(1e-2)
@@ -408,7 +408,7 @@ mod tests {
408408
.with_rng(Xoshiro256Plus::seed_from_u64(42))
409409
.sample(3);
410410
let res = EgorBuilder::optimize(f_g24)
411-
.configure(|config| config.n_cstr(2).doe(&doe).n_iter(20).random_seed(42))
411+
.configure(|config| config.n_cstr(2).doe(&doe).max_iters(20).random_seed(42))
412412
.min_within(&xlimits)
413413
.run()
414414
.expect("Minimize failure");
@@ -435,7 +435,7 @@ mod tests {
435435
.qei_strategy(QEiStrategy::KrigingBeliever)
436436
.doe(&doe)
437437
.target(-5.5030)
438-
.n_iter(30)
438+
.max_iters(30)
439439
.random_seed(42)
440440
})
441441
.min_within(&xlimits)
@@ -459,15 +459,15 @@ mod tests {
459459
#[test]
460460
#[serial]
461461
fn test_mixsinx_ei_mixint_egor_builder() {
462-
let n_iter = 30;
462+
let max_iters = 30;
463463
let doe = array![[0.], [7.], [25.]];
464464
let xtypes = vec![XType::Int(0, 25)];
465465

466466
let res = EgorBuilder::optimize(mixsinx)
467467
.configure(|config| {
468468
config
469469
.doe(&doe)
470-
.n_iter(n_iter)
470+
.max_iters(max_iters)
471471
.target(-15.1)
472472
.infill_strategy(InfillStrategy::EI)
473473
.random_seed(42)
@@ -481,15 +481,15 @@ mod tests {
481481
#[test]
482482
#[serial]
483483
fn test_mixsinx_reclustering_mixint_egor_builder() {
484-
let n_iter = 30;
484+
let max_iters = 30;
485485
let doe = array![[0.], [7.], [25.]];
486486
let xtypes = vec![XType::Int(0, 25)];
487487

488488
let res = EgorBuilder::optimize(mixsinx)
489489
.configure(|config| {
490490
config
491491
.doe(&doe)
492-
.n_iter(n_iter)
492+
.max_iters(max_iters)
493493
.target(-15.1)
494494
.infill_strategy(InfillStrategy::EI)
495495
.random_seed(42)
@@ -503,15 +503,15 @@ mod tests {
503503
#[test]
504504
#[serial]
505505
fn test_mixsinx_wb2_mixint_egor_builder() {
506-
let n_iter = 30;
506+
let max_iters = 30;
507507
let xtypes = vec![XType::Int(0, 25)];
508508

509509
let res = EgorBuilder::optimize(mixsinx)
510510
.configure(|config| {
511511
config
512512
.regression_spec(egobox_moe::RegressionSpec::CONSTANT)
513513
.correlation_spec(egobox_moe::CorrelationSpec::SQUAREDEXPONENTIAL)
514-
.n_iter(n_iter)
514+
.max_iters(max_iters)
515515
.random_seed(42)
516516
})
517517
.min_within_mixint_space(&xtypes)
@@ -549,7 +549,7 @@ mod tests {
549549
let mut builder = env_logger::Builder::from_env(env);
550550
let builder = builder.target(env_logger::Target::Stdout);
551551
builder.try_init().ok();
552-
let n_iter = 10;
552+
let max_iters = 10;
553553
let xtypes = vec![
554554
XType::Cont(-5., 5.),
555555
XType::Enum(3),
@@ -562,7 +562,7 @@ mod tests {
562562
config
563563
.regression_spec(egobox_moe::RegressionSpec::CONSTANT)
564564
.correlation_spec(egobox_moe::CorrelationSpec::SQUAREDEXPONENTIAL)
565-
.n_iter(n_iter)
565+
.max_iters(max_iters)
566566
.random_seed(42)
567567
})
568568
.min_within_mixint_space(&xtypes)

ego/src/egor_config.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ use serde::{Deserialize, Serialize};
1010
/// Egor optimizer configuration
1111
#[derive(Clone, Serialize, Deserialize)]
1212
pub struct EgorConfig {
13-
/// Number of function iterations allocated to find the optimum (aka iteration budget)
14-
/// Note 1 : The number of cost function evaluations is deduced using the following formula (n_doe + n_iter)
15-
/// Note 2 : When q_points > 1, the number of cost function evaluations is (n_doe + n_iter * q_points)
13+
/// Max number of function iterations allocated to find the optimum (aka iteration budget)
14+
/// Note 1 : The number of cost function evaluations is deduced using the following formula (n_doe + max_iters)
15+
/// Note 2 : When q_points > 1, the number of cost function evaluations is (n_doe + max_iters * q_points)
1616
/// is is an upper bounds as some points may be rejected as being to close to previous ones.
17-
pub(crate) n_iter: usize,
17+
pub(crate) max_iters: usize,
1818
/// Number of starts for multistart approach used for hyperparameters optimization
1919
pub(crate) n_start: usize,
2020
/// Number of points returned by EGO iteration (aka qEI Multipoint strategy)
@@ -64,7 +64,7 @@ pub struct EgorConfig {
6464
impl Default for EgorConfig {
6565
fn default() -> Self {
6666
EgorConfig {
67-
n_iter: 20,
67+
max_iters: 20,
6868
n_start: 20,
6969
q_points: 1,
7070
n_doe: 0,
@@ -94,9 +94,9 @@ impl EgorConfig {
9494
self
9595
}
9696

97-
/// Sets allowed number of evaluation of the function under optimization
98-
pub fn n_iter(mut self, n_iter: usize) -> Self {
99-
self.n_iter = n_iter;
97+
/// Sets max number of iterations to optimize the objective function
98+
pub fn max_iters(mut self, max_iters: usize) -> Self {
99+
self.max_iters = max_iters;
100100
self
101101
}
102102

ego/src/egor_solver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ where
375375
.clusterings(clusterings)
376376
.sampling(sampling);
377377
initial_state.doe_size = doe.nrows();
378-
initial_state.max_iters = self.config.n_iter as u64;
378+
initial_state.max_iters = self.config.max_iters as u64;
379379
initial_state.added = doe.nrows();
380380
initial_state.no_point_added_retries = no_point_added_retries;
381381
initial_state.cstr_tol = self

ego/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
//!
2929
//! // We ask for 10 evaluations of the objective function to get the result
3030
//! let res = EgorBuilder::optimize(xsinx)
31-
//! .configure(|config| config.n_iter(10))
31+
//! .configure(|config| config.max_iters(10))
3232
//! .min_within(&array![[0.0, 25.0]])
3333
//! .run()
3434
//! .expect("xsinx minimized");
@@ -64,7 +64,7 @@
6464
//! }
6565
//! }
6666
//!
67-
//! let n_iter = 10;
67+
//! let max_iters = 10;
6868
//! let doe = array![[0.], [7.], [25.]]; // the initial doe
6969
//!
7070
//! // We define input as being integer
@@ -73,7 +73,7 @@
7373
//! let res = EgorBuilder::optimize(mixsinx)
7474
//! .configure(|config|
7575
//! config.doe(&doe) // we pass the initial doe
76-
//! .n_iter(n_iter)
76+
//! .max_iters(max_iters)
7777
//! .infill_strategy(InfillStrategy::EI)
7878
//! .random_seed(42))
7979
//! .min_within_mixint_space(&xtypes) // We build a mixed-integer optimizer

src/egor.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,16 @@ impl Egor {
240240
/// This function finds the minimum of a given function `fun`
241241
///
242242
/// # Parameters
243-
/// n_iter:
244-
/// the iteration budget, number of fun calls is n_doe + q_points * n_iter.
243+
/// max_iters:
244+
/// the iteration budget, number of fun calls is n_doe + q_points * max_iters.
245245
///
246246
/// # Returns
247247
/// optimization result
248248
/// x_opt (array[1, nx]): x value where fun is at its minimum subject to constraint
249249
/// y_opt (array[1, nx]): fun(x_opt)
250250
///
251-
#[pyo3(signature = (n_iter = 20))]
252-
fn minimize(&self, py: Python, n_iter: usize) -> PyResult<OptimResult> {
251+
#[pyo3(signature = (max_iters = 20))]
252+
fn minimize(&self, py: Python, max_iters: usize) -> PyResult<OptimResult> {
253253
let fun = self.fun.to_object(py);
254254
let obj = move |x: &ArrayView2<f64>| -> Array2<f64> {
255255
Python::with_gil(|py| {
@@ -309,7 +309,7 @@ impl Egor {
309309
.configure(|config| {
310310
let mut config = config
311311
.n_cstr(self.n_cstr)
312-
.n_iter(n_iter)
312+
.max_iters(max_iters)
313313
.n_start(self.n_start)
314314
.n_doe(self.n_doe)
315315
.cstr_tol(&cstr_tol)

0 commit comments

Comments
 (0)