Genetic Algorithm with Array as variable

5 visualizaciones (últimos 30 días)
Scott Lowrie
Scott Lowrie el 11 de Ag. de 2016
Comentada: Set Eng el 6 de Oct. de 2020
So say I have some array at the beginning of a very long code. And at the end the program outputs a single value. How do I get the genetic algorithm tool to change the values of each element in the array to minimize the output value? This may be something simple but I cannot find a method or example on how to do this. Thanks for your time!

Respuesta aceptada

Alan Weiss
Alan Weiss el 11 de Ag. de 2016
All you have to do is change your array to a row vector, something like this:
input = x(:)';
Here x represents your array of variables (known as decision variables) that the optimizer changes to minimize the output value (known as the objective function or, for ga, the fitness function). Then input is the set of variables that ga evaluates for finding a minimum.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  5 comentarios
Walter Roberson
Walter Roberson el 5 de Oct. de 2020
Your Question does not appear to be posted yet?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by