How to find the index of a particular child when using use parallel = True option in genetic algorithm optimizer?
2 次查看(过去 30 天)
显示 更早的评论
Sravan Kumar Kanchari Bavajigari
2022-6-30
评论: Sravan Kumar Kanchari Bavajigari
2022-7-6
I am using genetic algorithm in global optimization toolbox.
I have an objective function within which
i) I create directories
ii) run an executable using system() command
iii) write and read files to evaluate the objective function for a given child
I would like to evaluate the objective function for different childs in parallel using the UseParallel=True option. However, I would need to know the index of the particular child in the population so that I can create a directory with the name corresponding to the index of the particular child. This would mean that I will need to use the index of the child within my objective function.
So, my question is how to find the index of a particular child when using the parallel option in genetic algorithm optimizer?
It would also be great if there is a solution to find the index during parallel operation of other optimizers (eg: patternsearch, etc.,) in MATLAB as well. Thank you.
0 个评论
采纳的回答
Matt J
2022-6-30
编辑:Matt J
2022-6-30
If you have the Parallel Computing Toolbox, set UseParallel=false and UseVectorized=true. Then, inside your objective function and constraints, you will have access to all poopulation members and their indices. You can use parfor or other PCT tools to parallel-split the operations within those functions, but with full control over the splitting.
3 个评论
Matt J
2022-6-30
编辑:Matt J
2022-6-30
When UseVectorized=true, the fitness and constraint functions will be passed an MxN matrix in each generation, where each row of the matrix is a population member. In this case, your functions are responsible for processing the entire population in a single call, see also,
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!