Skip to content

Commit

Permalink
updating stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Bulletninja committed Sep 12, 2014
1 parent e84c500 commit 9c1a2e4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
9 changes: 6 additions & 3 deletions CruzayMutacion.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function offspring=CruzayMutacion(p,m,M,N,NP,orden)
function offspring=CruzayMutacion(p,m,M,N,NP,CR,orden)
%En la cruza se elige la información en común
%entre ambos padres, se elige con proabilidad CR
%a uno de los padres como "plantilla", y se permutan
Expand All @@ -16,7 +16,9 @@
%Aquí se puede utilizar CR
%proba CR para el padre
%y 1-CR para la madre, por ejemplo...
offspring=p;
if unifrnd(0,1)>=CR
offspring=permutarTrabajos(p,M,N,orden);
end
%Aquí se permutan las entradas que son distintas
%entre los padres
%len=length(c)
Expand All @@ -28,13 +30,14 @@
%Si el orden se toma en cuenta, no se permutan los trabajos
%se sigue el mismo procedimiento mencionado arriba, pero para
%cada trabajo, respetando el orden de los mismos
size(p);
p=reshape(p,M,N);
m=reshape(m,M,N);
offspring=reshape(offspring,M,N);
%size(offspring)
for i=1:N
%i, size(p), size(m)
offspring(:,i)==CruzayMutacion(p(:,i),m(:,i),M,1,NP,false);
offspring(:,i)=CruzayMutacion(p(:,i),m(:,i),M,1,NP,false);
end
offspring=offspring(:);
end
Expand Down
30 changes: 16 additions & 14 deletions EvoDif_scheduling.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [mejorindividuo, nfeval] = EvoDif_scheduling(NP,J,orden,generaciones)
function [mejorindividuo, nfeval] = EvoDif_scheduling(NP,J,CR,orden,generaciones)
%Minimización con Evolución diferencial
%Salidas
%--------------------
Expand Down Expand Up @@ -68,25 +68,27 @@

while((generacion < generaciones) && (mejorval>1.e-5))
% generacion
poblacion_vieja = poblacion;
%poblacion_vieja = poblacion;
%"barajar" población
ind = randperm(4);
a1 = randperm(NP);
rt = rem(rot+ind(1),NP);
a2 = a1(rt+1);
%ind = randperm(4);
% a1 = randperm(NP);
% rt = rem(rot+ind(1),NP);
% a2 = a1(rt+1);
% rt = rem(rot+ind(2),NP);
% a3 = a2(rt+1);
% rt = rem(rot+ind(3),NP);
% a4 = a3(rt+1);
% rt = rem(rot+ind(4),NP);
% a5 = a4(rt+1);

mp1 = poblacion_vieja(:,a1);
mp2 = poblacion_vieja(:,a2);
% mp1 = poblacion_vieja(:,a1);
% mp2 = poblacion_vieja(:,a2);
% mp3 = poblacion_vieja(:,a3);
% mp4 = poblacion_vieja(:,a4);
% mp5 = poblacion_vieja(:,a5);

for i=1:NP
mp1(:,i)=permutarTrabajos(J,M,N,orden);
mp2(:,i)=permutarTrabajos(J,M,N,orden);
end
for i=1:NP
mi(:,i)=mejorinditeracion;
end
Expand All @@ -98,7 +100,7 @@
%----------Mutación/Perturbación----------------
for i=1:NP
%offsprings
ui(:,i)=CruzayMutacion(mp1(:,i),mp2(:,i),M,N,NP,orden);
ui(:,i)=CruzayMutacion(mp1(:,i),mp2(:,i),M,N,NP,CR,orden);
end
% if (estrategia == 1) % DE/best/1
% ui = mi+F*(mp1-mp2);
Expand Down Expand Up @@ -129,10 +131,10 @@
end
mejorinditeracion = mejorindividuo;
%-----Salida---------------------------------------------
if (rem(generacion,1)==0)
if (rem(generacion,20)==0)
fprintf(1,'Iteracion: %d, Mejor: %f, NP %d\n ',generacion, mejorval, NP);
reshape(mejorindividuo,M,N)
scheduleCost(reshape(mejorindividuo,M,N))
%scheduleCost(mejorindividuo,M,N)
% scheduleCost(reshape(mejorindividuo,M,N))
%for n=1:(M*N)
% fprintf(1,'Mejor(%d) = %f\n\n', n,mejorindividuo(n));
%end
Expand Down
2 changes: 2 additions & 0 deletions costoSchedule.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
%máxima de las máquinas
%http://www2.informatik.hu-berlin.de/alcox/lehre/lvws1011/coalg/makespan_scheduling.pdf
J=reshape(J,M,N);
Jmax=repmat(max(J),M,1);
W = Jmax-J
c=max(sum(J,2));
end
8 changes: 6 additions & 2 deletions scheduleCost.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
function c=scheduleCost(J)
c=sum(max(J));
function c=scheduleCost(J,M,N)
J=reshape(J,M,N);
%Jmax=repmat(max(J),M,1);
%W = max(sum(Jmax-J,2));
%c=max(sum(J,2));
c=sum(max(J));
end

0 comments on commit 9c1a2e4

Please sign in to comment.