-
Notifications
You must be signed in to change notification settings - Fork 81
/
Assembly line scheduling
59 lines (50 loc) · 1.06 KB
/
Assembly line scheduling
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
#include <stdio.h>
#define NUM_LINE 2
#define NUM_STATION 6
int min(int a, int b)
{
return a < b ? a : b;
}
int carAssembly(int a[][NUM_STATION], int t[][NUM_STATION], int *e, int *x)
{
int T1[NUM_STATION], T2[NUM_STATION], i;
int k[NUM_STATION], k1[NUM_STATION];
T1[0] = e[0] + a[0][0];
T2[0] = e[1] + a[1][0];
for (i = 1; i < NUM_STATION; ++i)
{
if((T1[i-1]+a[0][i])< T2[i-1] + t[1][i] + a[0][i])
{
T1[i]=T1[i-1]+a[0][i];
}
else
{
T1[i]=T2[i-1] + t[1][i] + a[0][i];
}
if((T2[i-1]+a[1][i])< T1[i-1] + t[0][i] + a[1][i])
{
T2[i]=T2[i-1]+a[1][i];
}
else
{
T2[i]=T1[i-1] + t[0][i] + a[1][i];
}
}
for(i=0;i<NUM_STATION;i++)
if(T1[i]>T2[i])
printf("2-> ");
else
printf("1-> ");
printf("\n");
return min(T1[NUM_STATION-1] + x[0], T2[NUM_STATION-1] + x[1]);
}
int main()
{
int a[][NUM_STATION] = {{7, 9, 3, 4,8,4},
{8, 5, 6, 4,5,7}};
int t[][NUM_STATION] = {{0, 2, 3, 1,3,4},
{0, 2, 1, 2,2,1}};
int e[] = {2, 4}, x[] = {3, 2};
printf("\nMinimum time: %d\n", carAssembly(a, t, e, x));
return 0;
}