How to find fixed number of variables with value 1 using Genetic Algorithm with population type Bitstring ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am solving an objective function with Genetic Algorithm with population type bitstring (values 0 and 1 only) using toolbox.
The variables select rows of a matrix (10*10) and the objective function is to find a minimum value in a further calculated matrix using values from those rows.
The current variables are 10. So the the GA solves and find values of all 10 variables.
How to select a fix number of variables with a value of 1 ? example out of 10 variables, i need to find the solution of 1 for 5 variables only i.e. i want to find the 5 best rows from matrix.
0 commentaires
Réponse acceptée
Alan Weiss
le 14 Sep 2021
If I understand you correctly (and I might not have understood), you want to impose a linear constraint on the population x
sum(x,2) == 5
meaning each row (individual) has exactly 5 with value 1, the rest have value 0.
If that is what you are trying to do, then I believe that you need to impose custom creation, mutation, and possibly crossover functions. The creation and mutation functions should ensure that you maintain exactly five individuals that have value 1. Some crossover functions might do this automatically, but you would have to check to be sure.
Custom creation function syntax which also has details on using bitstring such as which built-in crossover functions are available
Alan Weiss
MATLAB mathematical toolbox documentation
5 commentaires
Alan Weiss
le 14 Sep 2021
mutation rate + crossover fraction = 1
Alan Weiss
MATLAB mathematical toolbox documentation
Plus de réponses (0)
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!