Can I write a Genetic algorithm code for multiple choice questions?

1 回表示 (過去 30 日間)
Mohan Lal
Mohan Lal 2015 年 4 月 12 日
コメント済み: Mohammad Abouali 2015 年 4 月 12 日
Hello.. Can anyone please help me? I have to write a GA code to find the solution case there are 10 questions with 4 choices which means there are 4^10 = 1,048,576 cases and one of them is the solution case. Cheap Youtube Views I have understood that the length of chromosomes must be 10 arrays and the size of population is also 10. I know nothing about coding and looked through some code examples and noticed that i have to calculate crossover, mutation, and fitness..
This is what I came up with for now. I found this example source on google, and I do not understand why there are popcurrent, popnext.. Thank you very much..

採用された回答

Mohammad Abouali
Mohammad Abouali 2015 年 4 月 12 日
編集済み: Mohammad Abouali 2015 年 4 月 12 日
use MATLAB's GA() command. Since you have four choices, then you are pretty much integer space.
nVars=10;
% there are 4 choices, so integer 1 to 4; set Lower and upper bounds.
LB = ones (nVars,1)
UB = 4 * ones(nVars,1);
x = ga(fitnessfcn,nVars,[],[],[],[],LB,UB,[],1:nVars)

その他の回答 (1 件)

Mohan Lal
Mohan Lal 2015 年 4 月 12 日
thanks sir

カテゴリ

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