Confused at best estimated feasible point from bayesopt?
3 views (last 30 days)
I've been trying to use bayesopt for a research problem and been getting mixed results. I decided to try it with a simple example to try and understand the algorithm better. Here's the code:
x = optimizableVariable('x', [0, 1], 'Type', 'real');
y = optimizableVariable('y', [0, 1], 'Type', 'real');
optimisation_variables = [x, y];
% Run bayesopt
results = bayesopt(@negSumSquared, optimisation_variables, 'MaxObjectiveEvaluations', 100, ...
'IsObjectiveDeterministic', true, 'AcquisitionFunctionName', 'expected-improvement-plus');
% Objective function
function result = negSumSquared(X)
result = -(X.x^2 + X.y^2);
When I run this bayesopt generates the surface and produces the following output:
Best observed feasible point:
Best estimated feasible point (according to models):
What's confusing me quite a lot then is the estimated best point according to models. When I run the following snippet:
X = 0:0.01:1;
Y = X;
for i = 1:length(X)
for j = 1:length(Y)
Z(i, j) = predict(results.ObjectiveFcnModel, [X(i), Y(j)]);
I can confirm that min(Z) = -2 when X = 1 and Y = 1 as I would expect. So where is bayesopt pulling its best estimated feasible point from if it is not from the objective function model, and why is it so off compared to the true solution and the fitted points?
Thanks a lot for the help,
Don Mathis on 23 Sep 2021
Thank you for reporting this. This turned out to be a bug in how bayesopt calculates upper confidence intervals when the model has very low uncertainty.
We'll fix this in a future release. In the meantime, you can work around it by setting 'IsObjectiveDeterministic', false
If that doesn't meet your needs, a more drastic workaround would be to make a 1-line change to the source code of the file BayesianOptimization.m in your installation. I can provide details if you want to go that route.