Borrar filtros
Borrar filtros

problem in coding of firefly algorithm

1 visualización (últimos 30 días)
Mudasir Ahmed
Mudasir Ahmed el 4 de Jun. de 2015
Comentada: Mudasir Ahmed el 4 de Jun. de 2015
hi
i am writing a program, in which i take three variable p1,p2,p3, and their object is to reach at position "t" in the shape of swarm. means at the end of iteration all variables value will be 50. here i just write the initial stage coding of program, but i am not getting the correct response. can any body help me, i will be thankful
regards
p1=10
p2=15
p3=20
t=50
b0=1
gamab=1 %initial
gamae=10 %final
for i=1:50
d1=t-p1
r1=sqrt((d1)^2)
d2=t-p2
r2=sqrt((d2)^2)
d3=t-p3
r3=sqrt((d3)^2)
gama=gamab+((gamae-gamab)*i)/50
c=gama^r1^2
b1=b0*exp(-c)
d=gama^r2^2
b2=b0*exp(-d)
e=gama^r3^2
b3=b0*exp(-e)
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 4 de Jun. de 2015
If you want the value of the variables to change, then you need to assign them new values inside the loop. You make calculations based upon t and p1, p2, p3, but you never change any of those in your loop.
  3 comentarios
Walter Roberson
Walter Roberson el 4 de Jun. de 2015
sqrt(d^2) is abs(d)
Mudasir Ahmed
Mudasir Ahmed el 4 de Jun. de 2015
sir, what about the whole program response.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by