MATLAB Examples

FireFly SELECTION DEMO

Contents

Initialize

clc
clear all
warning off all

DEMO 1

row=50;
col=10;
Data=randi([1,50],[row,col]);
disp('Data---->')
disp(Data)
nOfSelection=3;
nOfFireFlies=20;
itrationMax=100;
fun=@meandata;
[Selection , SelectionValue]=fireflySelection(Data,nOfSelection,nOfFireFlies,itrationMax,fun);
MinimizedData=Data(:,Selection);
disp('Selection---->')
disp(Selection)
disp('SelectionValue---->')
disp(SelectionValue)
Data---->
    21    21     2    17     6     3    34    47    20    17
    47    34    46    19    35    34     6    25    43     9
    22    24    44     7    38    18     6    32    39     8
     5     6    39    14    46    28    50    18     7    35
    23    45    39    30    38    41    42    27     2    47
     2    47    32    10    20    39    12    28    47    47
    22    36    22    22     3    49    26    18    12    21
    17    47     3    48    39    34    20    36    39    37
     6    45    11    10    17    47     4    16    35     8
    17    45    49    24     4    23    12    14     5     6
    23    41    28    18    35    33    21    22    44    25
    22    32    47    34    32     3    27     6    44    41
    32    10    48    40    10     9     6    41    39    42
    18    10    50    47    28    30     9    15     7    30
    25    22    29    15    13    19     3    47    24    31
     6    12    25    32    15    15    45    32     2    35
    18    19    46    28    50    24    38    37    34     9
    19     1    28    22    34    41    16    13    19    22
    24    20     9    29    19    29     3    14    11    23
    16     3    41    17     2    36    16    10     8    40
    22     1    45    10    34    23    29    15     1     9
    30    14    14     4    17    49    47    19     8    20
     9     6    39    39    13    26     5    40    37     7
     2     2    44    27    24    46    34     2    46     5
    38     6    36    13    43    15    15    25    20    42
    22    14    26     9    41    40    34    13    38    21
    12    13    28    19     1    30    35    30    45    19
    49    12    38    27    35    13    46    26    23    20
    25    14    33    22     2     7    38    27    37    31
     9    20    17    16    18    44    20    23    10    19
    35    29    49    35    25    47    31     9    32    49
    38    28     1    45    12    46    20    31    32    33
     5    49    21     5    30     8    28    29    10    17
     4    39     7    13    21    37     1    49    26    48
    37    17     7    25    47    25     1    27    11    14
    35    46    33    42    19    10     8    34    34    10
    10     3    46    23     8    46    32    44    30    41
    47    46     1    15    38    23    38    38    13    44
    20    14     8    50    12    10     5     8    19     9
     7    30    41    27    10     7    50    49     9    43
    17    13    26    28    27    40    45    47     9    41
    47     4    34    15     9    33    44    42    35    15
    32    27    48    11    44    23    19    12    29     6
    29    47    49    14    43    14    23    27    25    39
    42    33    13    38    22    47    44    36    34    26
    43     8    18    30     8    23    31    29    44    36
    10    15     4    26    35    29    36    33    19    10
     8     5    42    10    26     8    35    11    37    27
    28    14    45    16    45    22    18    16    10    40
    28    22    43    49    48     9    42    32    31    31

itration 1 best Atrraction value is 1672.399200
itration 2 best Atrraction value is 1616.010800
itration 3 best Atrraction value is 1616.010800
itration 4 best Atrraction value is 1562.616800
itration 5 best Atrraction value is 1562.616800
itration 6 best Atrraction value is 1562.616800
itration 7 best Atrraction value is 1562.616800
itration 8 best Atrraction value is 1562.616800
itration 9 best Atrraction value is 1562.616800
itration 10 best Atrraction value is 1562.616800
itration 11 best Atrraction value is 1562.616800
itration 12 best Atrraction value is 1562.616800
itration 13 best Atrraction value is 1562.616800
itration 14 best Atrraction value is 1562.616800
itration 15 best Atrraction value is 1562.616800
itration 16 best Atrraction value is 1562.616800
itration 17 best Atrraction value is 1562.616800
itration 18 best Atrraction value is 1562.616800
itration 19 best Atrraction value is 1562.616800
itration 20 best Atrraction value is 1562.616800
itration 21 best Atrraction value is 1562.616800
itration 22 best Atrraction value is 1562.616800
itration 23 best Atrraction value is 1562.616800
itration 24 best Atrraction value is 1562.616800
itration 25 best Atrraction value is 1562.616800
itration 26 best Atrraction value is 1562.616800
itration 27 best Atrraction value is 1562.616800
itration 28 best Atrraction value is 1562.616800
itration 29 best Atrraction value is 1562.616800
itration 30 best Atrraction value is 1562.616800
itration 31 best Atrraction value is 1562.616800
itration 32 best Atrraction value is 1562.616800
itration 33 best Atrraction value is 1562.616800
itration 34 best Atrraction value is 1562.616800
itration 35 best Atrraction value is 1562.616800
itration 36 best Atrraction value is 1562.616800
itration 37 best Atrraction value is 1562.616800
itration 38 best Atrraction value is 1562.616800
itration 39 best Atrraction value is 1562.616800
itration 40 best Atrraction value is 1562.616800
itration 41 best Atrraction value is 1562.616800
itration 42 best Atrraction value is 1562.616800
itration 43 best Atrraction value is 1562.616800
itration 44 best Atrraction value is 1562.616800
itration 45 best Atrraction value is 1562.616800
itration 46 best Atrraction value is 1562.616800
itration 47 best Atrraction value is 1562.616800
itration 48 best Atrraction value is 1562.616800
itration 49 best Atrraction value is 1562.616800
itration 50 best Atrraction value is 1562.616800
itration 51 best Atrraction value is 1562.616800
itration 52 best Atrraction value is 1562.616800
itration 53 best Atrraction value is 1562.616800
itration 54 best Atrraction value is 1562.616800
itration 55 best Atrraction value is 1562.616800
itration 56 best Atrraction value is 1562.616800
itration 57 best Atrraction value is 1562.616800
itration 58 best Atrraction value is 1562.616800
itration 59 best Atrraction value is 1562.616800
itration 60 best Atrraction value is 1562.616800
itration 61 best Atrraction value is 1562.616800
itration 62 best Atrraction value is 1562.616800
itration 63 best Atrraction value is 1562.616800
itration 64 best Atrraction value is 1562.616800
itration 65 best Atrraction value is 1562.616800
itration 66 best Atrraction value is 1562.616800
itration 67 best Atrraction value is 1562.616800
itration 68 best Atrraction value is 1562.616800
itration 69 best Atrraction value is 1562.616800
itration 70 best Atrraction value is 1562.616800
itration 71 best Atrraction value is 1562.616800
itration 72 best Atrraction value is 1562.616800
itration 73 best Atrraction value is 1562.616800
itration 74 best Atrraction value is 1562.616800
itration 75 best Atrraction value is 1562.616800
itration 76 best Atrraction value is 1562.616800
itration 77 best Atrraction value is 1562.616800
itration 78 best Atrraction value is 1562.616800
itration 79 best Atrraction value is 1562.616800
itration 80 best Atrraction value is 1562.616800
itration 81 best Atrraction value is 1562.616800
itration 82 best Atrraction value is 1562.616800
itration 83 best Atrraction value is 1562.616800
itration 84 best Atrraction value is 1562.616800
itration 85 best Atrraction value is 1562.616800
itration 86 best Atrraction value is 1562.616800
itration 87 best Atrraction value is 1562.616800
itration 88 best Atrraction value is 1562.616800
itration 89 best Atrraction value is 1562.616800
itration 90 best Atrraction value is 1562.616800
itration 91 best Atrraction value is 1562.616800
itration 92 best Atrraction value is 1562.616800
itration 93 best Atrraction value is 1562.616800
itration 94 best Atrraction value is 1562.616800
itration 95 best Atrraction value is 1562.616800
itration 96 best Atrraction value is 1562.616800
itration 97 best Atrraction value is 1562.616800
itration 98 best Atrraction value is 1562.616800
itration 99 best Atrraction value is 1562.616800
itration 100 best Atrraction value is 1562.616800
Selection---->
     1     4     2

SelectionValue---->
       1562.6

Demo 1 output

disp('MinimizedData---->')
disp(MinimizedData)
MinimizedData---->
    21    17    21
    47    19    34
    22     7    24
     5    14     6
    23    30    45
     2    10    47
    22    22    36
    17    48    47
     6    10    45
    17    24    45
    23    18    41
    22    34    32
    32    40    10
    18    47    10
    25    15    22
     6    32    12
    18    28    19
    19    22     1
    24    29    20
    16    17     3
    22    10     1
    30     4    14
     9    39     6
     2    27     2
    38    13     6
    22     9    14
    12    19    13
    49    27    12
    25    22    14
     9    16    20
    35    35    29
    38    45    28
     5     5    49
     4    13    39
    37    25    17
    35    42    46
    10    23     3
    47    15    46
    20    50    14
     7    27    30
    17    28    13
    47    15     4
    32    11    27
    29    14    47
    42    38    33
    43    30     8
    10    26    15
     8    10     5
    28    16    14
    28    49    22

DEMO 2

nOfSelection=4;
nOfFireFlies=10;
itrationMax=100;
fun=@stddata;
[Selection , SelectionValue]=fireflySelection(Data,nOfSelection,nOfFireFlies,itrationMax,fun);
MinimizedData=Data(:,Selection);
disp('Selection---->')
disp(Selection)
disp('SelectionValue---->')
disp(SelectionValue)
itration 1 best Atrraction value is 13.534824
itration 2 best Atrraction value is 13.049965
itration 3 best Atrraction value is 13.006154
itration 4 best Atrraction value is 13.006154
itration 5 best Atrraction value is 13.006154
itration 6 best Atrraction value is 13.006154
itration 7 best Atrraction value is 13.006154
itration 8 best Atrraction value is 13.006154
itration 9 best Atrraction value is 13.006154
itration 10 best Atrraction value is 13.006154
itration 11 best Atrraction value is 13.006154
itration 12 best Atrraction value is 13.006154
itration 13 best Atrraction value is 13.006154
itration 14 best Atrraction value is 13.006154
itration 15 best Atrraction value is 13.006154
itration 16 best Atrraction value is 13.006154
itration 17 best Atrraction value is 13.006154
itration 18 best Atrraction value is 13.006154
itration 19 best Atrraction value is 13.006154
itration 20 best Atrraction value is 13.006154
itration 21 best Atrraction value is 13.006154
itration 22 best Atrraction value is 13.006154
itration 23 best Atrraction value is 13.006154
itration 24 best Atrraction value is 13.006154
itration 25 best Atrraction value is 12.962525
itration 26 best Atrraction value is 12.962525
itration 27 best Atrraction value is 12.962525
itration 28 best Atrraction value is 12.962525
itration 29 best Atrraction value is 12.962525
itration 30 best Atrraction value is 12.962525
itration 31 best Atrraction value is 12.962525
itration 32 best Atrraction value is 12.962525
itration 33 best Atrraction value is 12.962525
itration 34 best Atrraction value is 12.962525
itration 35 best Atrraction value is 12.962525
itration 36 best Atrraction value is 12.962525
itration 37 best Atrraction value is 12.962525
itration 38 best Atrraction value is 12.962525
itration 39 best Atrraction value is 12.962525
itration 40 best Atrraction value is 12.962525
itration 41 best Atrraction value is 12.962525
itration 42 best Atrraction value is 12.962525
itration 43 best Atrraction value is 12.962525
itration 44 best Atrraction value is 12.962525
itration 45 best Atrraction value is 12.962525
itration 46 best Atrraction value is 12.962525
itration 47 best Atrraction value is 12.962525
itration 48 best Atrraction value is 12.962525
itration 49 best Atrraction value is 12.962525
itration 50 best Atrraction value is 12.962525
itration 51 best Atrraction value is 12.962525
itration 52 best Atrraction value is 12.962525
itration 53 best Atrraction value is 12.962525
itration 54 best Atrraction value is 12.962525
itration 55 best Atrraction value is 12.962525
itration 56 best Atrraction value is 12.962525
itration 57 best Atrraction value is 12.962525
itration 58 best Atrraction value is 12.962525
itration 59 best Atrraction value is 12.962525
itration 60 best Atrraction value is 12.962525
itration 61 best Atrraction value is 12.962525
itration 62 best Atrraction value is 12.962525
itration 63 best Atrraction value is 12.962525
itration 64 best Atrraction value is 12.962525
itration 65 best Atrraction value is 12.962525
itration 66 best Atrraction value is 12.962525
itration 67 best Atrraction value is 12.962525
itration 68 best Atrraction value is 12.962525
itration 69 best Atrraction value is 12.962525
itration 70 best Atrraction value is 12.962525
itration 71 best Atrraction value is 12.962525
itration 72 best Atrraction value is 12.962525
itration 73 best Atrraction value is 12.962525
itration 74 best Atrraction value is 12.962525
itration 75 best Atrraction value is 12.962525
itration 76 best Atrraction value is 12.962525
itration 77 best Atrraction value is 12.962525
itration 78 best Atrraction value is 12.962525
itration 79 best Atrraction value is 12.962525
itration 80 best Atrraction value is 12.962525
itration 81 best Atrraction value is 12.962525
itration 82 best Atrraction value is 12.962525
itration 83 best Atrraction value is 12.962525
itration 84 best Atrraction value is 12.962525
itration 85 best Atrraction value is 12.962525
itration 86 best Atrraction value is 12.962525
itration 87 best Atrraction value is 12.962525
itration 88 best Atrraction value is 12.962525
itration 89 best Atrraction value is 12.962525
itration 90 best Atrraction value is 12.962525
itration 91 best Atrraction value is 12.962525
itration 92 best Atrraction value is 12.962525
itration 93 best Atrraction value is 12.962525
itration 94 best Atrraction value is 12.962525
itration 95 best Atrraction value is 12.962525
itration 96 best Atrraction value is 12.962525
itration 97 best Atrraction value is 12.962525
itration 98 best Atrraction value is 12.962525
itration 99 best Atrraction value is 12.962525
itration 100 best Atrraction value is 12.962525
Selection---->
     1     8     4    10

SelectionValue---->
       12.963

Demo 2 output

disp('MinimizedData---->')
disp(MinimizedData)
MinimizedData---->
    21    47    17    17
    47    25    19     9
    22    32     7     8
     5    18    14    35
    23    27    30    47
     2    28    10    47
    22    18    22    21
    17    36    48    37
     6    16    10     8
    17    14    24     6
    23    22    18    25
    22     6    34    41
    32    41    40    42
    18    15    47    30
    25    47    15    31
     6    32    32    35
    18    37    28     9
    19    13    22    22
    24    14    29    23
    16    10    17    40
    22    15    10     9
    30    19     4    20
     9    40    39     7
     2     2    27     5
    38    25    13    42
    22    13     9    21
    12    30    19    19
    49    26    27    20
    25    27    22    31
     9    23    16    19
    35     9    35    49
    38    31    45    33
     5    29     5    17
     4    49    13    48
    37    27    25    14
    35    34    42    10
    10    44    23    41
    47    38    15    44
    20     8    50     9
     7    49    27    43
    17    47    28    41
    47    42    15    15
    32    12    11     6
    29    27    14    39
    42    36    38    26
    43    29    30    36
    10    33    26    10
     8    11    10    27
    28    16    16    40
    28    32    49    31