1212import warnings
1313from ..surrogate_modeling .gp import GaussianProcess
1414from .acquisition import LCBacquisition , EIacquisition
15+ from .evaluator import Evaluator
1516from ..problems .problem import Problem
1617from .optproblem import IpoptProb
1718
@@ -23,6 +24,7 @@ def __init__(self):
2324 self .xtrain = None # Training data
2425 self .ytrain = None # Training data
2526 self .prob = None # Problem structure
27+ self .evaluator = None # compute control objective evaluations
2628 self .bo_maxiter = 20 # Maximum number of Bayesian optimization steps
2729 self .n_start = 10 # estimating acquisition global optima by determining local optima n_start times and then determining the discrete max of that set
2830 self .batch_size = 1 # batch size
@@ -93,6 +95,9 @@ def __init__(self, prob:Problem, gpsurrogate:GaussianProcess, xtrain, ytrain,
9395 f"batched BO only supported for expected-improvement"
9496 self .setAcquisitionType (acquisition_type , batch_size )
9597
98+ self .evaluator = options .get ('evaluator' , Evaluator ())
99+ assert isinstance (self .evaluator , Evaluator )
100+
96101 if options and 'opt_solver' in options :
97102 opt_solver = options ['opt_solver' ]
98103 assert opt_solver in ["SLSQP" , "IPOPT" ], f"Invalid opt_solver: { opt_solver } "
@@ -196,7 +201,8 @@ def optimize(self):
196201 y_train_virtual = np .vstack ([y_train_virtual , y_virtual ])
197202
198203 # TODO: include a parallel evaluator
199- y_new = self .prob .evaluate (np .atleast_2d (x_train [- self .batch_size :]))
204+ y_new = self .evaluator .run (self .prob .evaluate , x_train [- self .batch_size :])
205+ #y_new = self.prob.evaluate(np.atleast_2d(x_train[-self.batch_size:]))
200206
201207
202208 y_train = np .vstack ([y_train , y_new ])
0 commit comments