How to find fixed number of variables with value 1 using Genetic Algorithm with population type Bitstring ?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Alan Weiss
2021년 9월 14일
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
Alan Weiss
2021년 9월 14일
mutation rate + crossover fraction = 1
Alan Weiss
MATLAB mathematical toolbox documentation
추가 답변 (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!