フィルターのクリア

Can I use the matrix to the variable genetic algorithm?

3 ビュー (過去 30 日間)
Ji-hwan Hwang
Ji-hwan Hwang 2015 年 12 月 1 日
コメント済み: Umber Saleem 2019 年 4 月 3 日
I want use matrix to variable.
y=cost(gene)
gene = ones(1,10)
A = [0,find(gene(i,:))];
Pre_Num = numel(A);
S = 0;
up = 0.6;
Dec = 0;
for j = 1:Pre_Num-1
cost1 = exp(-(0.5*(A(j+1)-S)^2))
term = dec_rel_a + (( A(j+1) -A(j))*(1 -up));
Dec = A(j+1) - term;
predict = exp(-(0.5*(A(j+1)- Dec))^2));
if (((1 - RM_a)*0.1) > (predict_rel_a - RM_a))
dec_rel_a = 0;
gene(i,A(j+1)=2;
temp_fit_val(j) = temp_fit_val(j) + 10000
impro_rate = 1;
else
temp_fit_val(j) = temp_fit_val(j) + 10
impro_rate = up;
end
fit_val(i) = fit_val(i) + temp_fit_val(j);
Dec = Dec + (( A(j+1) - A(j))*(1 - impro_rate));
S = A(j+1) - Dec;
end
I would like to know the optimal arrangement of the matrix using a genetic algorithm.

回答 (1 件)

Alan Weiss
Alan Weiss 2015 年 12 月 1 日
Sorry, I do not understand your code or your question. If you are using Global Optimization toolbox, then your individuals must be row vectors for the ga function. If you are trying to optimize individuals that are matrices, then convert each individual to a row vector using the command
xnew = x(:)';
To convert a row vector back to a matrix, use reshape.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 件のコメント
Umber Saleem
Umber Saleem 2019 年 4 月 3 日
Alan Weiss can I use reshape for specifying constraints as well?

サインインしてコメントする。

カテゴリ

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