How to constrain the Genetic Algorithm so that the variables are in the form of an n by m matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
채택된 답변
Matt J
2014년 5월 15일
편집: Matt J
2014년 5월 15일
Insert the following as the first line in your cost function
x=reshape(x,25,51);
Now it doesn't matter what shape the original input x, is.
댓글 수: 3
Matt J
2014년 5월 15일
편집: Matt J
2014년 5월 15일
So the problem is that the current cost function yourfunc(x) doesn't know the matrix dimensions in advance? You will have to wrap it in another function that does know the architecture and which reshapes the input accordingly, e.g.,
fitnessFunc=@(x) yourfunc(reshape(x,[M,N]))
Surely, you have something outside of yourfunc() that does know the architecture. How else does the matrix get into its intended shape in the first place?
추가 답변 (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!