Confused at best estimated feasible point from bayesopt?

4 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Don Mathis
Don Mathis il 23 Set 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
  3 Commenti
Don Mathis
Don Mathis il 24 Set 2021
It turns out that there are 2 lines you will need to add.
You'll need to start MATLAB with Administrator privileges on your system in order to change source files.
Once you are in MATLAB,
Change 1:
>> edit BayesianOptimization/GPF_UCI_OnPoints
The last full line of code in that function is
UCI(feasible) = norminv(1-Alpha, FMean, FSD);
Add this line immediately after that:
UCI(feasible & FSD==0) = FMean(FSD==0);
Change 2:
>> edit bayesoptim.expectedImprovement
The last full line of code in that function is
EI = FSD.*(GammaX.*PI + normpdf(GammaX, 0, 1));
Add this line immediately after that:
EI(PI==0) = 0;
Daniel Gordon
Daniel Gordon il 26 Set 2021
Thanks Don, making those edits has fixed the problem for me. Cheers!

Accedi per commentare.

Più risposte (0)

Tag

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by