Bonjour à toutes et à tous,

Je travaille sur la minimisation des pertes au niveau des flux du réseau électrique, Dans ce contexte je vais utiliser l'algorithme Firefly et j'ai pris l'exemple ci-dessous pour comprendre son principe de fonctionnement, mais je me coince sur la ligne qui me demande la fonction de fitness(j'ai essayé avec la fonction d'optimisation de Matlab ackleyfcn).

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function FFA 
clear all
clc
N=input('Please Enter the Number of Firefly: ');
clc
maxGen=input('Please Provide the Stopping Criteria: ');
clc
alpha=input('Please Enter the value of alpha: ');
clc
Beta0=input('Please enter the Initial attractiveness: '); 
clc 
gamma=input('Please Provide the Absorption Coefficient (gamma): ');
clc
fitness=input('Select the test function: ');
clc 
FIREFLY=input('Please Enter the Population of the FIREFLY: or\nPress zero(0) for the default population: '); 
clc
if    FIREFLY==0
    pop=rand(N); 
else 
    pop=FIREFLY;
end
popi=pop;
popj=rand(N);
Ii=objfunc(fitness,popi);
%this reprsent the light intesity of(pop)
%this reprsent the light intesity of(pop)
Ij=objfunc(fitness,popj);
%Ij=fitness+popj;
itr=0; 
while itr<maxGen 
    itr=itr+1; 
    for i=1:N 
        for j=1:N 
            r=sqrt((popi(i)-popi(j))^2+(popj(i)-pop(j))^2);
            if Ii<Ij 
                beta=Beta0*exp(-gamma*r.^2);
                Ii=popj(i).*(1-beta)+popj(j).*beta+alpha.*(rand-0.5);
            end
            beta=Beta0*exp(-gamma*r.^2);
            popi(i)=popi(i).*(1-beta)+popi(j).*beta+alpha.*(rand-0.5);
            popj(i)=popj(i).*(1-beta)+popj(j).*beta+alpha.*(rand-0.5); 
            Iinew=objfunc(fitness,popi(i)); Ijnew=objfunc(fitness,popj(i));
        end
    end
    if Iinew<Ijnew 
        Best_Soln=Iinew;
    else Best_Soln=Ijnew;
    end
end
disp(Best_Soln)

Merci d'avance