How to get XAtMinObjective at each iteration

1 次查看(过去 30 天)
Hi,
I know that at the end of a Bayesian optimisation using the bayesopt() function, the value of XAtMinObjective can be obtained. However, I would like to obtain this value, and preferrably save it using the OutputFcn option, for each iteration of the Bayesian optimisation process. Is there a way to do this? I suspect there may be since, when the plotting function is used, the minimum feasible point is plotted for each iteration.

回答(1 个)

Avadhoot
Avadhoot 2023-9-29
Hi Jonathan,
I infer from your question that you need a way to save the value of “XAtMinObjective” for each iteration. There is a built-in output function which can do this. You need to add the following line to your code to use it.
results = bayesopt(myFunction, vars,'OutputFcn',@saveToFile,'SaveFileName','myFile.mat')
This line performs the following functions:
  • saveToFile” is a built-in output function which saves the results of each stage to a file
  • The file name is specified by the name value pair of ‘SaveFileName
  • The object that is saved in this case is a BayesianOptimization instance.
You can access the “XAtMinObjective” property of the results using the following line of code:
minValue = result.XAtMinObjective;
Here, “result” is the saved BayesianOptimization instance.
You can find more information about the BayesianOptimization” object here:
For details about the built-in output functions for Bayesian Optimization refer the following links:
  1. Types of built-in functions: https://www.mathworks.com/help/stats/bayesian-optimization-output-functions.html#bvaz800-1:~:text=of%20the%20optimization.-,Built%2DIn,-Output%20Functions
  2. Syntax and Usage: https://www.mathworks.com/help/stats/bayesopt.html#d126e159918:~:text=Data%20Types%3A%20double-,OutputFcn,-%E2%80%94%20Function%20called
I hope it helps,
Regards,
Avadhoot.

类别

Help CenterFile Exchange 中查找有关 Model Building and Assessment 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by