Filter löschen
Filter löschen

Can I use the matrix to the variable genetic algorithm?

3 Ansichten (letzte 30 Tage)
Ji-hwan Hwang
Ji-hwan Hwang am 1 Dez. 2015
Kommentiert: Umber Saleem am 3 Apr. 2019
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.

Antworten (1)

Alan Weiss
Alan Weiss am 1 Dez. 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(:)';
To convert a row vector back to a matrix, use reshape.
Alan Weiss
MATLAB mathematical toolbox documentation

Community Treasure Hunt

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

Start Hunting!

Translated by