How to get XAtMinObjective at each iteration

조회 수: 4 (최근 30일)
Jonathan De Sousa
Jonathan De Sousa 2022년 4월 11일
답변: Avadhoot 2023년 9월 29일
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에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by