forked from dimasaryo/ACO---Dynamic-JSSP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dinamicjssp.asv
98 lines (87 loc) · 2.95 KB
/
dinamicjssp.asv
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
function []=dinamicjssp(firstjob,newjob,newjobtime)
%10042011
%input data awal
%fungsi inputstream digunakan untuk memproses data dari file .xls menjadi
%matriks waktu proses dan matriks mesin
[graph,machine,nodes]= inputstream(firstjob);
%parameter algoritma semut
Q = 1;
a = 1;
b = 1;
p =0.5;
t =0.01;
mactime=zeros(1,size(graph,2)); %semua mesin dalam keadaan bebas, setup time 0
jobtime=zeros(1,size(graph,1));
%cari rute terbaik dengan algoritma semut
[bestrute,setuptimes,machines]=ACO(graph,machine,nodes,Q,a,b,p,t,mactime,jobtime);
fprintf('makespan terkecil sebelum job baru datang adalah %d satuan waktu \n',max(bestrute));
%tampilkan hasil dari rute terbaik dalam bentuk diagram
subplot(2,1,1);
title({' ';' ';'Diagram hubungan waktu dengan job sebelum ada penambahan job';' '});
ylabel('Job');
xlabel('Waktu');
showmap(graph,bestrute,setuptimes,machines);
%cari dan simpan operasi yang berjalan sebelum job baru datang
column=2;
tempgraph=graph;
for i=2:size(bestrute,2)-1
if(setuptimes(1,i)<newjobtime)
selectednode(1,column)=bestrute(1,i);
selectednodesetuptime(1,column)=setuptimes(1,i);
selectednodemachines(1,column)=machines(1,i);
column=column+1;
row=ceil(bestrute(1,i)/size(graph,2));
columns=mod(bestrute(1,i),size(graph,2));
if(columns==0)
columns=3;
end
tempgraph(row,columns)=0;
end
end
selectednode(1,column)=0;
subplot(2,1,2);
title({' ';' ';'Diagram hubungan waktu dengan job setelah ada penambahan job';' '});
ylabel('Job');
xlabel('Waktu');
showmap(graph,selectednode,selectednodesetuptime,selectednodemachines);
%machine time dan jobtime yang baru
for i=2:size(selectednode,2)-1
row=ceil(selectednode(1,i)/size(graph,2));
column=mod(selectednode(1,i),size(graph,2));
if(column==0)
column=3;
end
mactime(1,machine(row,column))= selectednodesetuptime(1,i)+graph(row,column);
jobtime(1,row)= selectednodesetuptime(1,i)+graph(row,column);
end
jobtime = [jobtime newjobtime]
%susun graf baru dari operasi yang belum dikerjakan ditambah job yang
%datang
newgraph = zeros(size(graph,1),size(graph,2));
newmachine = zeros(size(graph,1),size(graph,2));
for i=1:size(tempgraph,1)
column=1;
for j=1:size(tempgraph,2)
if(tempgraph(i,j)~=0)
newgraph(i,column)=tempgraph(i,j);
newmachine(i,column)=machine(i,j);
column=column+1;
end
end
end
[ngraph,nmachine,nnodes]= inputstream(newjob);
for i=1:size(ngraph,1)
jobtime = [jobtime newjobtime]
newgraph=[newgraph;ngraph];
newmachine=[newmachine;nmachine];
k=1;
for i=1:size(newgraph,1)
for j=1:size(newgraph,2)
newnodes(i,j)=k;
k=k+1;
end
end
%cari rute terbaik menggunakan algoritma semut
[bestrute,setuptimes,machines]=ACO(newgraph,newmachine,newnodes,Q,a,b,p,t,mactime,jobtime);
fprintf('makespan terkecil setelah job baru datang adalah %d satuan waktu \n',max(bestrute));
showmap(newgraph,bestrute,setuptimes,machines);