-
Notifications
You must be signed in to change notification settings - Fork 0
/
mutation.m
75 lines (52 loc) · 1.98 KB
/
mutation.m
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function [propagate]=mutation(crossover_population,no_plan_job,no_mac_plan_job,machine_time,no_op_plan_job,transport_time)
mutation_population=[];
mutation_population=crossover_population;
%disp(mutation_population);
for j=1:1:2
c1=ceil(rand(1)*6);
p1=no_plan_job(c1);
if(c1==1)
p2=0;
else
p2=no_plan_job(c1-1);
end
p3=p1-p2;
pp=p2+ceil(rand(1)*p3);
mutation_population(j,c1)=pp;
for k=1:1:6
a=no_mac_plan_job(pp,k);
if k==1
if pp==1
b=0;
else
b=no_mac_plan_job(pp-1,6);
end
else
b=no_mac_plan_job(pp,k-1);
end
w=b+ceil(rand(1)*(a-b));
%now move to the machine_time to get the details of the selected
%machine for a particular opeartion
if w~=b % it means opeartion exist
mutation_population(j,6+12*(c1-1)+2*(k-1)+1)=machine_time(w,1); %6 for the process plan,12 for the each process plan(0-11,12-23....),2*(k-1 for travesrsing along those 12 bits,+1 for machine & +2 for time)
mutation_population(j,6+12*(c1-1)+2*(k-1)+2)=machine_time(w,2);
else
break;% if w==b it means this particular opration k does not exist in a plan so k+1 also wont exist
end
end
end
%disp('sabse alag');
%disp(mutation_population);
%disp('ye lo mutation');
%disp(mutation_population);
zz=[];
zz=cal_pre_fitness_log(mutation_population,2,transport_time,no_op_plan_job);
propagate=[];
if(zz(1,1)>zz(2,1))
propagate(1,:)=mutation_population(2,:);
elseif(zz(1,1)<=zz(2,1))
propagate(1,:)=mutation_population(1,:);
end
%disp('mutation wlaa propagate');
%disp(propagate);
% disp(zz);