diff --git a/bayes_optim/base.py b/bayes_optim/base.py index ac56857..dd6ab99 100644 --- a/bayes_optim/base.py +++ b/bayes_optim/base.py @@ -39,6 +39,7 @@ def __init__( eval_type: str = "list", DoE_size: Optional[int] = None, warm_data: Tuple = None, + initial_guess: np.ndarray = None, n_point: int = 1, acquisition_fun: str = "EI", acquisition_par: dict = None, @@ -291,7 +292,9 @@ def ask( else: # take the initial DoE n_point = self._DoE_size if n_point is None else n_point msg = f"asking {n_point} points (using DoE):" - X = self.create_DoE(n_point, fixed=fixed) + X = self.create_DoE(n_point, fixed=fixed, initial_guess=not self.initial_guess is None) + self.logger.info('*** Find me') + self.logger.info(X) if len(X) == 0: raise AskEmptyError() @@ -360,7 +363,7 @@ def tell( self.iter_count += 1 self.hist_f.append(xopt.fitness) - def create_DoE(self, n_point: int, fixed: Dict = None) -> List: + def create_DoE(self, n_point: int, fixed: Dict = None, initial_guess=False) -> List: """get the initial sample points using Design of Experiemnt (DoE) methods Parameters @@ -377,7 +380,14 @@ def create_DoE(self, n_point: int, fixed: Dict = None) -> List: search_space = self.search_space.filter(fixed.keys(), invert=True) count = 0 - DoE = [] + if initial_guess and not self.initial_guess is None: + # assert self.initial_guess.shape[0] == self.dim or self.initial_guess.shape[1] == self.dim + # assert all([isinstance(_, float) for _ in self.initial_guess[:, self.r_index].ravel()]) + # assert all([isinstance(_, int) for _ in self.initial_guess[:, self.i_index].ravel()]) + # assert all([isinstance(_, str) for _ in self.initial_guess[:, self.d_index].ravel()]) + DoE = [self.initial_guess] + else: + DoE = [] while n_point: # NOTE: random sampling could generate duplicated points again # keep sampling until getting enough points