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 Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by