I am trying to find a good way to use bayesian optimization that will give me the optimal simulation parameters that can approximate the experimental output closely. Below I wrote a code that first train the simuation data with gaussian process regression. Then I define a custom distance metric (i.e. relative error) which needs to be minimized in order to optimize the simulation input parameters.
X = [0.1 0.5; 0.2 0.6; 0.4 0.2; 0.8 0.9];
Y = [3.6;3.7;3.3;4.1];
Model = fitrgp(X,Y,'KernelFunction','squaredexponential');
Yr = 3.2;
options = optimset('Display','iter','PlotFcns',@optimplotfval);
[x,fval,exitflag,output] = fminsearch(@(x)abs((predict(Model,x)-Yr)/Yr),[0.1 0.5],options)
I know that Bayesian optimisation is the use of Gaussian processes for global optimisation.
How can I define the custom distance metric as objective function for bayesian optimization?