Reference #
Honestly, I’m not familiar with BayesianOPT, the opinions mentioned stem from the below. 👇
Advantages & Algorithm Principle #
Here we are going to talk about the advantages & algorithm principle of BayesianOPT. If you only want to konw how to use it, you can read the #Advantage
section, then go to the MATLAB Practice
Advantages #
Algorithm Principle #
MATLAB Practice #
Well, we can put Bayesian Optimization into practice even though we don’t understand it, using the predefined function of MATLAB, the bayesopt
. Here is the official guidance of the function: bayesopt
Final code display #
% define the obj function
function y = objectiveFcn(x)
y = (1 - x.x1)^2 + 100 * (x.x2 - x.x1^2)^2;
end
% define the variables
vars = [optimizableVariable('x1', [-2, 2])
optimizableVariable('x2', [-2, 2])];
% conduce the optimizer
results = bayesopt(@objectiveFcn, vars, ...
'AcquisitionFunctionName', 'expected-improvement-plus', ...
'MaxObjectiveEvaluations', 30, ...
'IsObjectiveDeterministic', true, ...
'Verbose', 1);
% get result
bestPoint = results.XAtMinObjective;
bestObjective = results.MinObjective;
% result output
fprintf('最优解 x1: %.4f, x2: %.4f\n', bestPoint.x1, bestPoint.x2);
fprintf('最优目标值: %.4f\n', bestObjective);
I’d commit that the code is generated by AI. 🥲 AI is a better coder, at least when comparing with me. 🫠
Parameters Explaination #
Params | Meaning |
---|---|
AcquisitionFunctionName |
select a Acquisition Function, which determines the method how bayesopt choose the next acquisition point |
MaxObjectiveEvaluations |
the maximize evalu turns |
IsObjectiveDeterministic |
If the obj function contains noise, set to true ; Otherwise, set to false |
Verbose |
Determine the detailing extend of console output, the complete output includes many figures. |
Want more detailed information? Refer to the Offical document: bayesopt. It’s more completed and with amount of examples.
It’s basic for every MathModeler to read the offical document. 😝