Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial guess added to DOE #20

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions bayes_optim/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down