Confused at best estimated feasible point from bayesopt?

3 views (last 30 days)
Daniel Gordon on 23 Sep 2021
Commented: Daniel Gordon on 26 Sep 2021
Hi,
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:
% Variables
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);
end
When I run this bayesopt generates the surface and produces the following output:
Best observed feasible point:
x y
_______ _______
0.99962 0.99902
Best estimated feasible point (according to models):
x y
_________ _______
0.0004718 0.99888
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)]);
end
end
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,
Daniel

Don Mathis on 23 Sep 2021
Hi Daniel,
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.
Thanks,
-Don
Daniel Gordon on 26 Sep 2021
Thanks Don, making those edits has fixed the problem for me. Cheers!

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!