Genetic Algorithm with Array as variable

4 次查看(过去 30 天)
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!

采纳的回答

Alan Weiss
Alan Weiss 2016-8-11
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 个评论
Walter Roberson
Walter Roberson 2020-10-5
Your Question does not appear to be posted yet?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by