Can I use the matrix to the variable genetic algorithm?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Alan Weiss
el 1 de Dic. de 2015
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 comentario
Ver también
Categorías
Más información sobre Genetic Algorithm en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!