Can I use the matrix to the variable genetic algorithm?
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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(:)';
Alan Weiss
MATLAB mathematical toolbox documentation
1 个评论
另请参阅
类别
在 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!