How to get XAtMinObjective at each iteration

1 Ansicht (letzte 30 Tage)
Jonathan De Sousa
Jonathan De Sousa am 11 Apr. 2022
Beantwortet: Avadhoot am 29 Sep. 2023
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.

Antworten (1)

Avadhoot
Avadhoot am 29 Sep. 2023
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.

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by