Gene Boundaries for Genetic Algorithm
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
TADA
le 14 Fév 2019
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 commentaires
Voir également
Catégories
En savoir plus sur Genetic Algorithm dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!