|
8 | 8 | //! ```no_run
|
9 | 9 | //! use ndarray::{array, Array2, ArrayView1, ArrayView2, Zip};
|
10 | 10 | //! use egobox_doe::{Lhs, SamplingMethod};
|
11 |
| -//! use egobox_ego::{EgorBuilder, EgorConfig, InfillStrategy, InfillOptimizer, ObjFunc, EgorSolver}; |
| 11 | +//! use egobox_ego::{EgorBuilder, EgorConfig, InfillStrategy, InfillOptimizer, ObjFunc, EgorSolver, to_xtypes}; |
12 | 12 | //! use egobox_moe::MoeParams;
|
13 | 13 | //! use rand_xoshiro::Xoshiro256Plus;
|
14 | 14 | //! use ndarray_rand::rand::SeedableRng;
|
|
25 | 25 | //! y
|
26 | 26 | //! }
|
27 | 27 | //! let rng = Xoshiro256Plus::seed_from_u64(42);
|
28 |
| -//! let xlimits = array![[-2., 2.], [-2., 2.]]; |
| 28 | +//! let xtypes = to_xtypes(&array![[-2., 2.], [-2., 2.]]); |
29 | 29 | //! let fobj = ObjFunc::new(rosenb);
|
30 | 30 | //! let config = EgorConfig::default();
|
31 |
| -//! let solver: EgorSolver<MoeParams<f64, Xoshiro256Plus>> = EgorSolver::new(config, &xlimits, rng); |
| 31 | +//! let solver: EgorSolver<MoeParams<f64, Xoshiro256Plus>> = EgorSolver::new(config, &xtypes, rng); |
32 | 32 | //! let res = Executor::new(fobj, solver)
|
33 | 33 | //! .configure(|state| state.max_iters(20))
|
34 | 34 | //! .run()
|
|
47 | 47 | //! ```no_run
|
48 | 48 | //! use ndarray::{array, Array2, ArrayView1, ArrayView2, Zip};
|
49 | 49 | //! use egobox_doe::{Lhs, SamplingMethod};
|
50 |
| -//! use egobox_ego::{EgorBuilder, EgorConfig, InfillStrategy, InfillOptimizer, ObjFunc, EgorSolver}; |
| 50 | +//! use egobox_ego::{EgorBuilder, EgorConfig, InfillStrategy, InfillOptimizer, ObjFunc, EgorSolver, to_xtypes}; |
51 | 51 | //! use egobox_moe::MoeParams;
|
52 | 52 | //! use rand_xoshiro::Xoshiro256Plus;
|
53 | 53 | //! use ndarray_rand::rand::SeedableRng;
|
|
83 | 83 | //! let rng = Xoshiro256Plus::seed_from_u64(42);
|
84 | 84 | //! let xlimits = array![[0., 3.], [0., 4.]];
|
85 | 85 | //! let doe = Lhs::new(&xlimits).sample(10);
|
| 86 | +//! let xtypes = to_xtypes(&xlimits); |
86 | 87 | //!
|
87 | 88 | //! let fobj = ObjFunc::new(f_g24);
|
88 | 89 | //!
|
|
94 | 95 | //! .target(-5.5080);
|
95 | 96 | //!
|
96 | 97 | //! let solver: EgorSolver<MoeParams<f64, Xoshiro256Plus>> =
|
97 |
| -//! EgorSolver::new(config, &xlimits, rng); |
| 98 | +//! EgorSolver::new(config, &xtypes, rng); |
98 | 99 | //!
|
99 | 100 | //! let res = Executor::new(fobj, solver)
|
100 | 101 | //! .configure(|state| state.max_iters(40))
|
@@ -218,36 +219,9 @@ impl<SB: SurrogateBuilder> EgorSolver<SB> {
|
218 | 219 | /// Constructor of the optimization of the function `f` with specified random generator
|
219 | 220 | /// to get reproducibility.
|
220 | 221 | ///
|
221 |
| - /// The function `f` should return an objective value but also constraint values if any. |
222 |
| - /// Design space is specified by the matrix `xlimits` which is `[nx, 2]`-shaped |
223 |
| - /// the ith row contains lower and upper bounds of the ith component of `x`. |
224 |
| - pub fn new( |
225 |
| - config: EgorConfig, |
226 |
| - xlimits: &ArrayBase<impl Data<Elem = f64>, Ix2>, |
227 |
| - rng: Xoshiro256Plus, |
228 |
| - ) -> Self { |
229 |
| - let env = Env::new().filter_or("EGOBOX_LOG", "info"); |
230 |
| - let mut builder = Builder::from_env(env); |
231 |
| - let builder = builder.target(env_logger::Target::Stdout); |
232 |
| - builder.try_init().ok(); |
233 |
| - EgorSolver { |
234 |
| - config: EgorConfig { |
235 |
| - xtypes: Some(to_xtypes(xlimits)), // align xlimits and xtypes |
236 |
| - ..config |
237 |
| - }, |
238 |
| - xlimits: xlimits.to_owned(), |
239 |
| - surrogate_builder: SB::new_with_xtypes(&to_xtypes(xlimits)), |
240 |
| - rng, |
241 |
| - } |
242 |
| - } |
243 |
| - |
244 |
| - /// Constructor of the optimization of the function `f` with specified random generator |
245 |
| - /// to get reproducibility. This constructor is used for mixed-integer optimization |
246 |
| - /// when `f` has discrete inputs to be specified with list of xtypes. |
247 |
| - /// |
248 | 222 | /// The function `f` should return an objective but also constraint values if any.
|
249 | 223 | /// Design space is specified by a list of types for input variables `x` of `f` (see [`XType`]).
|
250 |
| - pub fn new_with_xtypes(config: EgorConfig, xtypes: &[XType], rng: Xoshiro256Plus) -> Self { |
| 224 | + pub fn new(config: EgorConfig, xtypes: &[XType], rng: Xoshiro256Plus) -> Self { |
251 | 225 | let env = Env::new().filter_or("EGOBOX_LOG", "info");
|
252 | 226 | let mut builder = Builder::from_env(env);
|
253 | 227 | let builder = builder.target(env_logger::Target::Stdout);
|
|
0 commit comments