How to order 'n' no of populations in ascending order based on their fitness for a minimization objective in matlab

5 ビュー (過去 30 日間)
How to order 'n' no of populations in ascending order based on their fitness for a minimization objective in matlab?
  2 件のコメント
dhiman banerjee
dhiman banerjee 2019 年 9 月 20 日
Thank you for the reply. But this code gives fitness value of te each population in acending order. My problem is - that to reorder each population (i.e rows of the population matrix) as per the fitness value of each population in ascending order (Minimization objective)
Kindly help me in this point.
Syed Ahmed
Syed Ahmed 2022 年 11 月 24 日
Try this i had the same issue as you.
fitnessVector = [106; 100; 120; 104]; % fitness value
popu = [12 11 67 89 56; % populationn vector
45 13 77 39 86;
92 54 67 79 76;
62 54 65 9 5];
[X,I] = sort(fitnessVector); % to get indexes of order
popu = [I,popu]; % add index order as first column
popu = sortrows(popu,'descend'); % sorts based on the first column of matrix
fitnessVector = X % fitness values
fitnessVector = 4×1
100 104 106 120
popu(:,1) = []; % remove first column from population.

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

採用された回答

thoughtGarden
thoughtGarden 2019 年 9 月 19 日
編集済み: thoughtGarden 2019 年 9 月 20 日
I'm assuming you already have the fitness of each population according to the minimization objective. If this is the case, you will simply obtain the index order from the "sort" function while using the "direction" parameter.
sortedIndex = sort(fitnessVector, [],'ascend');
If you found this answer to be correct, please accept it. Otherwise, please add aditional comments so that it may be improved.

その他の回答 (0 件)

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by