Gene Boundaries for Genetic Algorithm
조회 수: 8 (최근 30일)
이전 댓글 표시
I am a bit stuck, as I am trying to set dynamic boundaries to the integers in the chromosomes, as they are made. For example, if a chromosome has the specific value [1 2 3 4 5 6], I was to ensure that the sum of the values is equal to a spefic number. How could i do that ?
댓글 수: 0
답변 (1개)
TADA
2019년 2월 14일
data = randi(4, 1, 400);
seq = 1:6;
% if you mean the sum of that sequence you are looking for
x = sum(seq, 2);
if any(strfind(data, seq)) && sum(seq, 2) == x
disp('great success')
end
% or if you mean the sum of the whole vector:
x = sum(data, 2);
if any(strfind(data, seq)) && sum(data, 2) == x
disp('great success')
end
댓글 수: 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!