Open zhangsiyu1103 opened 4 years ago
Can you share the code you are trying to run, and full stack trace of the error? Otherwise it would be very difficult to diagnose
Here is the code.
parameter_space = ParameterSpace([DiscreteParameter('x1',input_data["maxtrain"] ), DiscreteParameter('x2', input_data["epochs"])])
num_data_points = 8
design = LatinDesign(parameter_space)
X = design.get_samples(num_data_points)
Y = f(X)
constrains = g(X)
model_gpy = GPRegression(X,Y)
model_cons_gpy = GPRegression(X,constrains)
#the line below is equivalent to exact_feval = true in gpyopt
model_gpy.Gaussian_noise.constrain_fixed(1e-6, warning=False)
model_cons_gpy.Gaussian_noise.constrain_fixed(1e-6, warning=False)
model_gpy.optimize()
model_cons_gpy.optimize()
model_emukit = GPyModelWrapper(model_gpy)
model_cons = GPyModelWrapper(model_cons_gpy)
expected_improvement = ExpectedImprovement(model = model_emukit)
bayesopt_loop =UnknownConstraintBayesianOptimizationLoop(
model_objective = model_emukit,
model_constraint = model_cons,
space = parameter_space,
acquisition = expected_improvement,
batch_size = 1)
print("running optimization")
bayesopt_loop.run_loop(f, 100)
result = bayesopt_loop.get_results()
Here's the full stack trace
Traceback (most recent call last):
File "emukit_test.py", line 331, in
I realized that the "Y_constraint not found" error occurs because after the first optimization run, the results of loop_state does not include the extra_output because there is no extra_output in the run_loop function. Essentially, the reason is that the constraint function is not evaluated in the loop such that the loop_state for constraint is not updated.
I am trying modify both the update functions in loop_state and the run_loop function in the outer_loop to include the constraint function.
I tried to use the UnknownConstraintBayesianOptimizationLoop to optimize my objective function with constraint. However, I have a couple of issues with this loop.
First, when I initialize the loop with two gpy models and try to run it with "run_loop", I found the error "Y_constraint not found in results object". Tracing back to the function, I am wondering is there anything wrong with the create_loop_state function called in UnknownConstraintBayesianOptimizationLoop constructor.
Moreover, since run_loop only takes the objective function as a input, it can only update the objective model. However, from my understanding for the https://arxiv.org/abs/1403.5607 paper, the constraint model should also be updated with each iteration when a new constrained value calculated, but I don't see a implementation on this. Therefore, I am wondering that whether this part has not be implemented yet or I misunderstood it?