Any way to get bayesopt current iteration number in the objective function?

4 vues (au cours des 30 derniers jours)
Nbay
Nbay le 3 Fév 2023
Réponse apportée : Atharva le 8 Août 2023
So in my objective function, results are saved to the drive on every iteration. Right now I am using the tempname() function to create non-conflicting filenames. Because I am using parallel optimization, there is no easy way to match the files to the iteration number and thus to the results.
In the single threaded case I could just use a global variable or even just sort the files by date and time. But in parallel, it is unclear which thread is excuting which part first and this could lead to the file creation/modification times not matching the order of iterations.
The easiest solution would be to base the filename on the iteration number, but I haven't found a way of accessing this information in the objective function.

Réponses (1)

Atharva
Atharva le 8 Août 2023
Hi Nbay,
When using parallel optimization in MATLAB, you can generate filenames based on the iteration number by incorporating the getCurrentTask function. This function retrieves the current task's ID, which can be used to differentiate filenames across parallel workers.
I hope this helps.

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by