How to find the index of a particular child when using use parallel = True option in genetic algorithm optimizer?

1 visualización (últimos 30 días)
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.

Respuesta aceptada

Matt J
Matt J el 30 de Jun. de 2022
Editada: Matt J el 30 de Jun. de 2022
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 comentarios
Matt J
Matt J el 30 de Jun. de 2022
Editada: Matt J el 30 de Jun. de 2022
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,

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Genetic Algorithm en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by