I have multiple vectors of order (1000*24)have calculated the fitness of all these.Now the want the maximum out of fitness and want the corresponding vectors and index of that
2 ビュー (過去 30 日間)
古いコメントを表示
AA
0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0
0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0
0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0
0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1
0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0
0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 0
fitness=1/1+cost
Cost is calculated from price
p=[ 1 4 2 3 5 6 7 8 9 4 11 12 13 14 2 3 4 5 2 4 5 6 7 8]
I want to sort the fitness and want the maximum out of that values and also the corresponding vector and its index,related to max fitness value.
2 件のコメント
dpb
2022 年 10 月 15 日
What part does AA play in any of this? There's nothing about fitness, cost that is usable here; there's nothing to find the maximum of.
But max has the option to return the indes of a maximum; using that on whatever it is that is the values that do have something to take the maximum of will let you return whatever related data is needed.
回答 (1 件)
dpb
2022 年 10 月 17 日
>> Clansize_11=size(AA)
>> Clansize =
10 24
>>
will return a 2-vector of the number rows/columns of AA. What then do you think is the purpose of
for i=1:Clansize_11
if AA(i)<=Clansize_11
...
will just operate over
>> for i=1:Clansize_11,disp([i AA(i) AA(i)<=Clansize_11]),end
1 0 1 1
2 0 1 1
3 0 1 1
4 0 1 1
5 0 1 1
6 0 1 1
7 0 1 1
8 0 1 1
9 0 1 1
10 0 1 1
>>
the first column of the array, (shown by the first column above is "i", but given that AA contains nothing but 0/1, the test is going to be true for every element in the array, even though only the first column will be tested.
On top of which, the logical test will also return a 2-vector the size of the 2-vector Clansize_11 of the test against [10 24] of either a 0 or 1 (since the first column is all 0, it's just 0 <=[10 24] which as the last two columns shows, is going to be one everywhere.
If it is intended that AA is a logical variable of when to compute the E variable, then use the MATLAB array operations and the times, .* "dot" operators; there's no need for a loop.
Energy=Pr_kw.*AA;
Cost=Price_kw*Energy;
TotalCost=sum(Cost,2);
Fitness=1./(1+TotalCost);
At this point it shouldn't be hard to find the other statistics you've outlined...
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Hypothesis Tests についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!