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.

채택된 답변

Alan Weiss
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
Alan Weiss 2021년 9월 14일
mutation rate + crossover fraction = 1
Alan Weiss
MATLAB mathematical toolbox documentation
Ankur Shah
Ankur Shah 2021년 9월 16일
편집: Ankur Shah 2021년 9월 16일
Can you share the source of it i.e ."mutation rate + crossover fraction = 1" ?
Also is it possible to know the creation, crossover and mutaiton function which matlab uses for solving it ?. I couldn't find in the documentation.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by