Genetic Algorithm with Array as variable

조회 수: 5 (최근 30일)
Scott Lowrie
Scott Lowrie 2016년 8월 11일
댓글: Set Eng 2020년 10월 6일
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