-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathAssembly Line Scheduling.BAK
101 lines (101 loc) · 1.89 KB
/
Assembly Line Scheduling.BAK
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
99
100
101
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int i, n, f, le;
int a[2][10], t[2][9], e[2], x[2], f1[10], f2[10], l[2][10];
void stations()
{
int j, i=le;
printf("\n Optimal Path:");
for(j=1; j<n; ++j)
{
i=l[i-1][j];
printf("\n Line %d", i);
printf("\n Station %d", j);
}
i=le;
printf("\n Line %d", i);
printf("\n Station %d", n);
printf("\n");
}
void fastestWay()
{
f1[0]=e[0]+a[0][0];
f2[0]=e[1]+a[1][0];
int j;
for(j=1; j<n; ++j)
{
if((f1[j-1]+a[0][j])<=(f2[j-1]+t[1][j-1]+a[0][j]))
{
f1[j]=f1[j-1]+a[0][j];
l[0][j]=1;
}
else
{
f1[j]=f2[j-1]+t[1][j-1]+a[0][j];
l[0][j]=2;
}
if((f2[j-1]+a[1][j])<=(f1[j-1]+t[0][j-1]+a[1][j]))
{
f2[j]=f2[j-1]+a[i][j];
l[1][j]=2;
}
else
{
f2[j]=f1[j-1]+t[0][j-1]+a[1][j];
l[1][j]=1;
}
}
if((f1[n-1]+x[0])<=(f2[n-1]+x[1]))
{
f=f1[n-1]+x[0];
le=1;
}
else
{
f=f2[n-1]+x[1];
le=2;
}
stations();
}
int main()
{
int j;
printf("\n Assembly Line Scheduling");
printf("\n Enter the no. of nodes:");
scanf("%d", &n);
printf("\n Enter entry values:");
for(i=0; i<2; i++)
scanf("%d", &e[j]);
printf("\n Enter the exit values:");
for(i=0; i<2; i++)
scanf("%d", &x[i]);
printf("\n Enter the station times of line S1:");
for(i=0; i<n; ++i)
scanf("%d", &a[0][i]);
printf("\n Enter the station times of line S2:");
for(i=0; i<n; ++i)
scanf("%d", &a[1][i]);
printf("\n Enter transaction times from line S1:");
for(i=0; i<n-1; ++i)
scanf("%d", &t[0][i]);
printf("\n Enter transaction times from line S2:");
for(i=0; i<n-1; ++i)
scanf("%d", &t[1][i]);
fastestWay();
printf("\n Cost of Optimal Path is:");
i=1;
printf("For Path[%d]->\t", i);
for(j=0; j<n; j++)
printf("S[%d][%d]=%d\t", i, j+1, f1[j]);
printf("Total Cost is:%d", f);
printf("\n");
i=2;
printf("For Path[%d]->\t", i);
for(j=0; j<n; j++)
printf("S[%d][%d]=%d\t", i, j+1, f2[j]);
f=f2[n-1]+x[1];
printf("Total Cost is:%d", f);
getch();
return 0;
}