... | ... |
@@ -7,27 +7,19 @@ import { filter, flatten, identity, map, pluck, range, times } from 'rambda'; |
7 | 7 |
import uuid from 'uuid/v4'; |
8 | 8 |
import { selectAlgorithms, fastestResult, najneomeskanejsiResult } from './selectAlgorithm'; |
9 | 9 |
|
10 |
-// const algoData = [ |
|
11 |
-// [ |
|
12 |
-// { startTime: 1, endTime: 3, processor: 1, name: 'UI dizajnér' }, |
|
13 |
-// { startTime: 4, endTime: 6, processor: 1, name: 'UX dizajnér' }, |
|
14 |
-// { startTime: 6, endTime: 10, processor: 1, name: 'UI dizajnér' }, |
|
15 |
-// ] |
|
16 |
-// ]; |
|
17 |
-// |
|
18 |
-// const data = normalizeData(algoData); |
|
19 |
- |
|
20 | 10 |
class App extends PureComponent { |
21 | 11 |
state = { ganttData: null }; |
22 | 12 |
|
23 |
- onFormSubmit = ({ preempt, rows }) => { |
|
24 |
- const algorithmNames = selectAlgorithms(rows, preempt); |
|
13 |
+ onFormSubmit = ({ preempt, flowShop, rows }) => { |
|
14 |
+ const algorithmNames = selectAlgorithms(rows, preempt, flowShop == '1'); |
|
25 | 15 |
|
26 | 16 |
if (!algorithmNames) { |
27 | 17 |
alert('Pre zvolenú konfiguráciu sa nenašiel vhodný algoritmus'); |
28 | 18 |
return; |
29 | 19 |
} |
30 | 20 |
|
21 |
+ console.log(algorithmNames); |
|
22 |
+ |
|
31 | 23 |
const results = map(algorithmName => { |
32 | 24 |
const algorithm = algorithms[algorithmName]; |
33 | 25 |
|
... | ... |
@@ -36,7 +28,12 @@ class App extends PureComponent { |
36 | 36 |
if (algorithmName === 'johnson' || algorithmName === 'palmer' || algorithmName === 'grupt' || algorithmName === 'campbel') { |
37 | 37 |
jobTimes = times(i => ({ |
38 | 38 |
jobId: uuid(), |
39 |
- operations: map(j => ({ t: rows[j].jobs[i].t }), range(0, rows.length)) |
|
39 |
+ operations: map(j => |
|
40 |
+ rows[j].jobs[i] ? { |
|
41 |
+ t: rows[j].jobs[i].t, |
|
42 |
+ name: rows[j].jobs[i].name |
|
43 |
+ } : undefined, range(0, rows.length) |
|
44 |
+ ) |
|
40 | 45 |
}), rows[0].jobs.length); |
41 | 46 |
} else if (algorithmName === 'mcnaught' || algorithmName === 'vahy') { |
42 | 47 |
jobTimes = flatten(pluck('jobs', rows)); |
... | ... |
@@ -61,6 +58,7 @@ class App extends PureComponent { |
61 | 61 |
// console.log(rows[1].jobs); |
62 | 62 |
|
63 | 63 |
const result = algorithm(jobTimes, rows.length); |
64 |
+ console.log(result); |
|
64 | 65 |
return result; |
65 | 66 |
}, algorithmNames); |
66 | 67 |
|
... | ... |
@@ -78,7 +76,7 @@ class App extends PureComponent { |
78 | 78 |
|
79 | 79 |
const ganttData = normalizeData(validResults[fastestIndex]); |
80 | 80 |
|
81 |
- console.log(validResults[fastestIndex]); |
|
81 |
+ // console.log(validResults[fastestIndex]); |
|
82 | 82 |
|
83 | 83 |
this.setState({ |
84 | 84 |
ganttData |
... | ... |
@@ -92,7 +90,6 @@ class App extends PureComponent { |
92 | 92 |
<div style={{ padding: 20 }}> |
93 | 93 |
<Form onSubmit={this.onFormSubmit} /> |
94 | 94 |
{ganttData && <Gantt data={ganttData}/>} |
95 |
- {/*<Gantt data={data} />*/} |
|
96 | 95 |
</div> |
97 | 96 |
); |
98 | 97 |
} |
... | ... |
@@ -1,12 +1,11 @@ |
1 | 1 |
import { |
2 |
- addIndex, |
|
3 | 2 |
find, |
4 | 3 |
map, |
5 | 4 |
propEq, |
6 | 5 |
reduce, |
7 | 6 |
range, |
8 | 7 |
times, |
9 |
- last |
|
8 |
+ last, filter, identity |
|
10 | 9 |
} from 'rambda'; |
11 | 10 |
import type { JobId } from '../../types'; |
12 | 11 |
import { createSchedule as johnson, updateCTime } from '../johnson'; |
... | ... |
@@ -14,33 +13,30 @@ import { max } from 'ramda'; |
14 | 14 |
|
15 | 15 |
type JobOperations = { |
16 | 16 |
jobId: JobId, |
17 |
- operations: Array<{ t: number }> |
|
17 |
+ operations: Array<{ t: number, name: string }> |
|
18 | 18 |
}; |
19 | 19 |
|
20 | 20 |
type JobOperationsWithC = { |
21 | 21 |
jobId: JobId, |
22 |
- operations: Array<{ t: number, c: number }> |
|
22 |
+ operations: Array<{ t: number, c: number, name: string }> |
|
23 | 23 |
}; |
24 | 24 |
|
25 |
-export const fillCorrupted = (jobsOperations: JobOperations[]) => { |
|
26 |
- const maxOperationsCount = reduce((acc, { operations }) => max(operations.length, acc), 0, jobsOperations); |
|
27 |
- |
|
28 |
- return map( |
|
25 |
+export const fillCorrupted = (jobsOperations: JobOperations[], processorsCount) => |
|
26 |
+ map( |
|
29 | 27 |
({ operations, ...rest }) => { |
30 | 28 |
const fixedOperations = [...operations]; |
31 |
- fixedOperations.length = maxOperationsCount; |
|
29 |
+ fixedOperations.length = processorsCount; |
|
32 | 30 |
|
33 | 31 |
return { |
34 | 32 |
...rest, |
35 |
- operations: fixedOperations.fill({ t: 0 }, operations.length, maxOperationsCount) |
|
33 |
+ operations: map(o => o || { t: 0 }, fixedOperations) |
|
36 | 34 |
}; |
37 | 35 |
}, |
38 | 36 |
jobsOperations |
39 |
- ) |
|
40 |
-}; |
|
37 |
+ ); |
|
41 | 38 |
|
42 | 39 |
export const createSchedule = (jobsOperations: JobOperations[], processorsCount: number): JobOperationsWithC[] => { |
43 |
- jobsOperations = fillCorrupted(jobsOperations); |
|
40 |
+ jobsOperations = fillCorrupted(jobsOperations, processorsCount); |
|
44 | 41 |
|
45 | 42 |
const allSchedules = map(k => { |
46 | 43 |
const jobsOperationsForK = map((jobsOperation: JobOperations) => { |
... | ... |
@@ -57,8 +53,7 @@ export const createSchedule = (jobsOperations: JobOperations[], processorsCount: |
57 | 57 |
|
58 | 58 |
const jobsOperationsOrderTemplate = johnson(jobsOperationsForK); |
59 | 59 |
|
60 |
- const mapWithIndex = addIndex(map); |
|
61 |
- const jobsOperationsReordered = mapWithIndex((jobOperationTemplate, i) => { |
|
60 |
+ const jobsOperationsReordered = map(jobOperationTemplate => { |
|
62 | 61 |
const { operations } = find(propEq('jobId', jobOperationTemplate.jobId), jobsOperations); |
63 | 62 |
return { |
64 | 63 |
jobId: jobOperationTemplate.jobId, |
... | ... |
@@ -89,6 +84,7 @@ export default (jobsOperations: JobOperations[], processorsCount: number) => { |
89 | 89 |
processor: i + 1, |
90 | 90 |
startTime: jobTime.operations[i].c - jobTime.operations[i].t, |
91 | 91 |
endTime: jobTime.operations[i].c, |
92 |
+ name: jobTime.operations[i].name |
|
92 | 93 |
}), schedule) |
93 | 94 |
, processorsCount); |
94 | 95 |
}; |
95 | 96 |
\ No newline at end of file |
... | ... |
@@ -27,14 +27,14 @@ test('create schedule', () => { |
27 | 27 |
|
28 | 28 |
test('create gantt', () => { |
29 | 29 |
const jobsWithOperations = [ |
30 |
- { jobId: 1, operations: [ { t: 12 }, { t: 8 }, { t: 11 } ] }, |
|
31 |
- { jobId: 2, operations: [ { t: 6 }, { t: 13 }, { t: 19 } ] }, |
|
32 |
- { jobId: 3, operations: [ { t: 15 }, { t: 10 }, { t: 18 } ] }, |
|
33 |
- { jobId: 4, operations: [ { t: 16 }, { t: 7 }, { t: 21 } ] }, |
|
34 |
- { jobId: 5, operations: [ { t: 4 }, { t: 4 }, { t: 20 } ] }, |
|
35 |
- { jobId: 6, operations: [ { t: 3 }, { t: 12 }, { t: 13 } ] }, |
|
36 |
- { jobId: 7, operations: [ { t: 17 }, { t: 6 }, { t: 8 } ] }, |
|
37 |
- { jobId: 8, operations: [ { t: 10 }, { t: 2 }, { t: 25 } ] }, |
|
30 |
+ { jobId: 1, operations: [ { t: 12, name: 'a' }, { t: 8, name: 'b' }, { t: 11, name: 'c' } ] }, |
|
31 |
+ { jobId: 2, operations: [ { t: 6, name: 'a' }, { t: 13, name: 'b' }, { t: 19, name: 'c' } ] }, |
|
32 |
+ { jobId: 3, operations: [ { t: 15, name: 'a' }, { t: 10, name: 'b' }, { t: 18, name: 'c' } ] }, |
|
33 |
+ { jobId: 4, operations: [ { t: 16, name: 'a' }, { t: 7, name: 'b' }, { t: 21, name: 'c' } ] }, |
|
34 |
+ { jobId: 5, operations: [ { t: 4, name: 'a' }, { t: 4, name: 'b' }, { t: 20, name: 'c' } ] }, |
|
35 |
+ { jobId: 6, operations: [ { t: 3, name: 'a' }, { t: 12, name: 'b' }, { t: 13, name: 'c' } ] }, |
|
36 |
+ { jobId: 7, operations: [ { t: 17, name: 'a' }, { t: 6, name: 'b' }, { t: 8 , name: 'c'} ] }, |
|
37 |
+ { jobId: 8, operations: [ { t: 10, name: 'a' }, { t: 2, name: 'b' }, { t: 25, name: 'c' } ] }, |
|
38 | 38 |
]; |
39 | 39 |
|
40 | 40 |
const template = createGantt(jobsWithOperations, 3); |
... | ... |
@@ -44,30 +44,30 @@ test('create gantt', () => { |
44 | 44 |
expect(template[1].length).toBe(8); |
45 | 45 |
expect(template[2].length).toBe(8); |
46 | 46 |
|
47 |
- expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 4 }); |
|
48 |
- expect(template[0][1]).toEqual({ processor: 1, startTime: 4, endTime: 14 }); |
|
49 |
- expect(template[0][2]).toEqual({ processor: 1, startTime: 14, endTime: 17 }); |
|
50 |
- expect(template[0][3]).toEqual({ processor: 1, startTime: 17, endTime: 23 }); |
|
51 |
- expect(template[0][4]).toEqual({ processor: 1, startTime: 23, endTime: 39 }); |
|
52 |
- expect(template[0][5]).toEqual({ processor: 1, startTime: 39, endTime: 54 }); |
|
53 |
- expect(template[0][6]).toEqual({ processor: 1, startTime: 54, endTime: 66 }); |
|
54 |
- expect(template[0][7]).toEqual({ processor: 1, startTime: 66, endTime: 83 }); |
|
47 |
+ expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 4, name: 'a' }); |
|
48 |
+ expect(template[0][1]).toEqual({ processor: 1, startTime: 4, endTime: 14, name: 'a' }); |
|
49 |
+ expect(template[0][2]).toEqual({ processor: 1, startTime: 14, endTime: 17, name: 'a' }); |
|
50 |
+ expect(template[0][3]).toEqual({ processor: 1, startTime: 17, endTime: 23, name: 'a' }); |
|
51 |
+ expect(template[0][4]).toEqual({ processor: 1, startTime: 23, endTime: 39, name: 'a' }); |
|
52 |
+ expect(template[0][5]).toEqual({ processor: 1, startTime: 39, endTime: 54, name: 'a' }); |
|
53 |
+ expect(template[0][6]).toEqual({ processor: 1, startTime: 54, endTime: 66, name: 'a' }); |
|
54 |
+ expect(template[0][7]).toEqual({ processor: 1, startTime: 66, endTime: 83, name: 'a' }); |
|
55 | 55 |
|
56 |
- expect(template[1][0]).toEqual({ processor: 2, startTime: 4, endTime: 8 }); |
|
57 |
- expect(template[1][1]).toEqual({ processor: 2, startTime: 14, endTime: 16 }); |
|
58 |
- expect(template[1][2]).toEqual({ processor: 2, startTime: 17, endTime: 29 }); |
|
59 |
- expect(template[1][3]).toEqual({ processor: 2, startTime: 29, endTime: 42 }); |
|
60 |
- expect(template[1][4]).toEqual({ processor: 2, startTime: 42, endTime: 49 }); |
|
61 |
- expect(template[1][5]).toEqual({ processor: 2, startTime: 54, endTime: 64 }); |
|
62 |
- expect(template[1][6]).toEqual({ processor: 2, startTime: 66, endTime: 74 }); |
|
63 |
- expect(template[1][7]).toEqual({ processor: 2, startTime: 83, endTime: 89 }); |
|
56 |
+ expect(template[1][0]).toEqual({ processor: 2, startTime: 4, endTime: 8, name: 'b' }); |
|
57 |
+ expect(template[1][1]).toEqual({ processor: 2, startTime: 14, endTime: 16, name: 'b' }); |
|
58 |
+ expect(template[1][2]).toEqual({ processor: 2, startTime: 17, endTime: 29, name: 'b' }); |
|
59 |
+ expect(template[1][3]).toEqual({ processor: 2, startTime: 29, endTime: 42, name: 'b' }); |
|
60 |
+ expect(template[1][4]).toEqual({ processor: 2, startTime: 42, endTime: 49, name: 'b' }); |
|
61 |
+ expect(template[1][5]).toEqual({ processor: 2, startTime: 54, endTime: 64, name: 'b' }); |
|
62 |
+ expect(template[1][6]).toEqual({ processor: 2, startTime: 66, endTime: 74, name: 'b' }); |
|
63 |
+ expect(template[1][7]).toEqual({ processor: 2, startTime: 83, endTime: 89, name: 'b' }); |
|
64 | 64 |
|
65 |
- expect(template[2][0]).toEqual({ processor: 3, startTime: 8, endTime: 28 }); |
|
66 |
- expect(template[2][1]).toEqual({ processor: 3, startTime: 28, endTime: 53 }); |
|
67 |
- expect(template[2][2]).toEqual({ processor: 3, startTime: 53, endTime: 66 }); |
|
68 |
- expect(template[2][3]).toEqual({ processor: 3, startTime: 66, endTime: 85 }); |
|
69 |
- expect(template[2][4]).toEqual({ processor: 3, startTime: 85, endTime: 106 }); |
|
70 |
- expect(template[2][5]).toEqual({ processor: 3, startTime: 106, endTime: 124 }); |
|
71 |
- expect(template[2][6]).toEqual({ processor: 3, startTime: 124, endTime: 135 }); |
|
72 |
- expect(template[2][7]).toEqual({ processor: 3, startTime: 135, endTime: 143 }); |
|
65 |
+ expect(template[2][0]).toEqual({ processor: 3, startTime: 8, endTime: 28, name: 'c' }); |
|
66 |
+ expect(template[2][1]).toEqual({ processor: 3, startTime: 28, endTime: 53, name: 'c' }); |
|
67 |
+ expect(template[2][2]).toEqual({ processor: 3, startTime: 53, endTime: 66, name: 'c' }); |
|
68 |
+ expect(template[2][3]).toEqual({ processor: 3, startTime: 66, endTime: 85, name: 'c' }); |
|
69 |
+ expect(template[2][4]).toEqual({ processor: 3, startTime: 85, endTime: 106, name: 'c' }); |
|
70 |
+ expect(template[2][5]).toEqual({ processor: 3, startTime: 106, endTime: 124, name: 'c' }); |
|
71 |
+ expect(template[2][6]).toEqual({ processor: 3, startTime: 124, endTime: 135, name: 'c' }); |
|
72 |
+ expect(template[2][7]).toEqual({ processor: 3, startTime: 135, endTime: 143, name: 'c' }); |
|
73 | 73 |
}); |
74 | 74 |
\ No newline at end of file |
... | ... |
@@ -6,16 +6,16 @@ import { fillCorrupted } from '../campbel'; |
6 | 6 |
|
7 | 7 |
type JobOperations = { |
8 | 8 |
jobId: JobId, |
9 |
- operations: Array<{ t: number }> |
|
9 |
+ operations: Array<{ t: number, name: string }> |
|
10 | 10 |
}; |
11 | 11 |
|
12 | 12 |
type JobOperationsWithC = { |
13 | 13 |
jobId: JobId, |
14 |
- operations: Array<{ t: number, c: number }> |
|
14 |
+ operations: Array<{ t: number, c: number, name: string }> |
|
15 | 15 |
}; |
16 | 16 |
|
17 | 17 |
export const createSchedule = (jobsOperations: JobOperations[], processorsCount: number): JobOperationsWithC[] => { |
18 |
- jobsOperations = fillCorrupted(jobsOperations); |
|
18 |
+ jobsOperations = fillCorrupted(jobsOperations, processorsCount); |
|
19 | 19 |
|
20 | 20 |
const jobsOperationsWithKoefs = map((jobsOperation: JobOperations) => { |
21 | 21 |
const ej = jobsOperation.operations[0].t < jobsOperation.operations[processorsCount - 1].t |
... | ... |
@@ -51,6 +51,7 @@ export default (jobsOperations: JobOperations[], processorsCount: number) => { |
51 | 51 |
processor: i + 1, |
52 | 52 |
startTime: jobTime.operations[i].c - jobTime.operations[i].t, |
53 | 53 |
endTime: jobTime.operations[i].c, |
54 |
+ name: jobTime.operations[i].name |
|
54 | 55 |
}), schedule) |
55 | 56 |
, processorsCount); |
56 | 57 |
}; |
57 | 58 |
\ No newline at end of file |
... | ... |
@@ -27,14 +27,14 @@ test('create schedule', () => { |
27 | 27 |
|
28 | 28 |
test('create gantt', () => { |
29 | 29 |
const jobsWithOperations = [ |
30 |
- { jobId: 1, operations: [ { t: 12 }, { t: 8 }, { t: 11 } ] }, |
|
31 |
- { jobId: 2, operations: [ { t: 6 }, { t: 13 }, { t: 19 } ] }, |
|
32 |
- { jobId: 3, operations: [ { t: 15 }, { t: 10 }, { t: 18 } ] }, |
|
33 |
- { jobId: 4, operations: [ { t: 16 }, { t: 7 }, { t: 21 } ] }, |
|
34 |
- { jobId: 5, operations: [ { t: 4 }, { t: 4 }, { t: 20 } ] }, |
|
35 |
- { jobId: 6, operations: [ { t: 3 }, { t: 12 }, { t: 13 } ] }, |
|
36 |
- { jobId: 7, operations: [ { t: 17 }, { t: 6 }, { t: 8 } ] }, |
|
37 |
- { jobId: 8, operations: [ { t: 10 }, { t: 2 }, { t: 25 } ] }, |
|
30 |
+ { jobId: 1, operations: [ { t: 12, name: 'a' }, { t: 8 , name: 'b'}, { t: 11, name: 'c' } ] }, |
|
31 |
+ { jobId: 2, operations: [ { t: 6, name: 'a' }, { t: 13, name: 'b' }, { t: 19, name: 'c' } ] }, |
|
32 |
+ { jobId: 3, operations: [ { t: 15, name: 'a' }, { t: 10, name: 'b' }, { t: 18, name: 'c' } ] }, |
|
33 |
+ { jobId: 4, operations: [ { t: 16, name: 'a' }, { t: 7 , name: 'b'}, { t: 21, name: 'c' } ] }, |
|
34 |
+ { jobId: 5, operations: [ { t: 4, name: 'a' }, { t: 4 , name: 'b'}, { t: 20, name: 'c' } ] }, |
|
35 |
+ { jobId: 6, operations: [ { t: 3, name: 'a' }, { t: 12, name: 'b' }, { t: 13, name: 'c' } ] }, |
|
36 |
+ { jobId: 7, operations: [ { t: 17, name: 'a' }, { t: 6 , name: 'b'}, { t: 8, name: 'c' } ] }, |
|
37 |
+ { jobId: 8, operations: [ { t: 10, name: 'a' }, { t: 2 , name: 'b'}, { t: 25, name: 'c' } ] }, |
|
38 | 38 |
]; |
39 | 39 |
|
40 | 40 |
const template = createGantt(jobsWithOperations, 3); |
... | ... |
@@ -44,30 +44,30 @@ test('create gantt', () => { |
44 | 44 |
expect(template[1].length).toBe(8); |
45 | 45 |
expect(template[2].length).toBe(8); |
46 | 46 |
|
47 |
- expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 4 }); |
|
48 |
- expect(template[0][1]).toEqual({ processor: 1, startTime: 4, endTime: 14 }); |
|
49 |
- expect(template[0][2]).toEqual({ processor: 1, startTime: 14, endTime: 17 }); |
|
50 |
- expect(template[0][3]).toEqual({ processor: 1, startTime: 17, endTime: 23 }); |
|
51 |
- expect(template[0][4]).toEqual({ processor: 1, startTime: 23, endTime: 39 }); |
|
52 |
- expect(template[0][5]).toEqual({ processor: 1, startTime: 39, endTime: 54 }); |
|
53 |
- expect(template[0][6]).toEqual({ processor: 1, startTime: 54, endTime: 66 }); |
|
54 |
- expect(template[0][7]).toEqual({ processor: 1, startTime: 66, endTime: 83 }); |
|
47 |
+ expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 4, name: 'a' }); |
|
48 |
+ expect(template[0][1]).toEqual({ processor: 1, startTime: 4, endTime: 14, name: 'a' }); |
|
49 |
+ expect(template[0][2]).toEqual({ processor: 1, startTime: 14, endTime: 17, name: 'a' }); |
|
50 |
+ expect(template[0][3]).toEqual({ processor: 1, startTime: 17, endTime: 23, name: 'a' }); |
|
51 |
+ expect(template[0][4]).toEqual({ processor: 1, startTime: 23, endTime: 39, name: 'a' }); |
|
52 |
+ expect(template[0][5]).toEqual({ processor: 1, startTime: 39, endTime: 54, name: 'a' }); |
|
53 |
+ expect(template[0][6]).toEqual({ processor: 1, startTime: 54, endTime: 66, name: 'a' }); |
|
54 |
+ expect(template[0][7]).toEqual({ processor: 1, startTime: 66, endTime: 83, name: 'a' }); |
|
55 | 55 |
|
56 |
- expect(template[1][0]).toEqual({ processor: 2, startTime: 4, endTime: 8 }); |
|
57 |
- expect(template[1][1]).toEqual({ processor: 2, startTime: 14, endTime: 16 }); |
|
58 |
- expect(template[1][2]).toEqual({ processor: 2, startTime: 17, endTime: 29 }); |
|
59 |
- expect(template[1][3]).toEqual({ processor: 2, startTime: 29, endTime: 42 }); |
|
60 |
- expect(template[1][4]).toEqual({ processor: 2, startTime: 42, endTime: 49 }); |
|
61 |
- expect(template[1][5]).toEqual({ processor: 2, startTime: 54, endTime: 64 }); |
|
62 |
- expect(template[1][6]).toEqual({ processor: 2, startTime: 66, endTime: 74 }); |
|
63 |
- expect(template[1][7]).toEqual({ processor: 2, startTime: 83, endTime: 89 }); |
|
56 |
+ expect(template[1][0]).toEqual({ processor: 2, startTime: 4, endTime: 8, name: 'b' }); |
|
57 |
+ expect(template[1][1]).toEqual({ processor: 2, startTime: 14, endTime: 16, name: 'b' }); |
|
58 |
+ expect(template[1][2]).toEqual({ processor: 2, startTime: 17, endTime: 29, name: 'b' }); |
|
59 |
+ expect(template[1][3]).toEqual({ processor: 2, startTime: 29, endTime: 42, name: 'b' }); |
|
60 |
+ expect(template[1][4]).toEqual({ processor: 2, startTime: 42, endTime: 49, name: 'b' }); |
|
61 |
+ expect(template[1][5]).toEqual({ processor: 2, startTime: 54, endTime: 64, name: 'b' }); |
|
62 |
+ expect(template[1][6]).toEqual({ processor: 2, startTime: 66, endTime: 74, name: 'b' }); |
|
63 |
+ expect(template[1][7]).toEqual({ processor: 2, startTime: 83, endTime: 89, name: 'b' }); |
|
64 | 64 |
|
65 |
- expect(template[2][0]).toEqual({ processor: 3, startTime: 8, endTime: 28 }); |
|
66 |
- expect(template[2][1]).toEqual({ processor: 3, startTime: 28, endTime: 53 }); |
|
67 |
- expect(template[2][2]).toEqual({ processor: 3, startTime: 53, endTime: 66 }); |
|
68 |
- expect(template[2][3]).toEqual({ processor: 3, startTime: 66, endTime: 85 }); |
|
69 |
- expect(template[2][4]).toEqual({ processor: 3, startTime: 85, endTime: 106 }); |
|
70 |
- expect(template[2][5]).toEqual({ processor: 3, startTime: 106, endTime: 124 }); |
|
71 |
- expect(template[2][6]).toEqual({ processor: 3, startTime: 124, endTime: 135 }); |
|
72 |
- expect(template[2][7]).toEqual({ processor: 3, startTime: 135, endTime: 143 }); |
|
65 |
+ expect(template[2][0]).toEqual({ processor: 3, startTime: 8, endTime: 28, name: 'c' }); |
|
66 |
+ expect(template[2][1]).toEqual({ processor: 3, startTime: 28, endTime: 53, name: 'c' }); |
|
67 |
+ expect(template[2][2]).toEqual({ processor: 3, startTime: 53, endTime: 66, name: 'c' }); |
|
68 |
+ expect(template[2][3]).toEqual({ processor: 3, startTime: 66, endTime: 85, name: 'c' }); |
|
69 |
+ expect(template[2][4]).toEqual({ processor: 3, startTime: 85, endTime: 106, name: 'c' }); |
|
70 |
+ expect(template[2][5]).toEqual({ processor: 3, startTime: 106, endTime: 124, name: 'c' }); |
|
71 |
+ expect(template[2][6]).toEqual({ processor: 3, startTime: 124, endTime: 135, name: 'c' }); |
|
72 |
+ expect(template[2][7]).toEqual({ processor: 3, startTime: 135, endTime: 143, name: 'c' }); |
|
73 | 73 |
}); |
74 | 74 |
\ No newline at end of file |
... | ... |
@@ -8,12 +8,12 @@ import { fillCorrupted } from '../campbel'; |
8 | 8 |
|
9 | 9 |
type JobOperations = { |
10 | 10 |
jobId: JobId, |
11 |
- operations: [{ t: number }, { t: number }] |
|
11 |
+ operations: [{ t: number, name: string }, { t: number, name: string }] |
|
12 | 12 |
}; |
13 | 13 |
|
14 | 14 |
type JobOperationsWithC = { |
15 | 15 |
jobId: JobId, |
16 |
- operations: [{ t: number, c: number }, { t: number, c: number }] |
|
16 |
+ operations: [{ t: number, c: number, name: string }, { t: number, c: number, name: string }] |
|
17 | 17 |
}; |
18 | 18 |
|
19 | 19 |
const findMinT = (operations) => |
... | ... |
@@ -73,7 +73,7 @@ export const updateCTime = (jobsOperations: JobOperations[], processorCount: num |
73 | 73 |
}; |
74 | 74 |
|
75 | 75 |
export const createSchedule = (jobsOperations: JobOperations[]): JobOperationsWithC[] => { |
76 |
- jobsOperations = fillCorrupted(jobsOperations); |
|
76 |
+ jobsOperations = fillCorrupted(jobsOperations, 2); |
|
77 | 77 |
|
78 | 78 |
let I = jobsOperations; |
79 | 79 |
let L = [[], []]; |
... | ... |
@@ -102,6 +102,7 @@ export default (jobsOperations: JobOperations[]) => { |
102 | 102 |
processor: i + 1, |
103 | 103 |
startTime: jobTime.operations[i].c - jobTime.operations[i].t, |
104 | 104 |
endTime: jobTime.operations[i].c, |
105 |
+ name: jobTime.operations[i].name |
|
105 | 106 |
}), schedule) |
106 | 107 |
, 2); |
107 | 108 |
}; |
108 | 109 |
\ No newline at end of file |
... | ... |
@@ -31,16 +31,16 @@ test('create schedule', () => { |
31 | 31 |
|
32 | 32 |
test('create gantt', () => { |
33 | 33 |
const jobsWithOperations = [ |
34 |
- { jobId: 1, operations: [ { t: 15 }, { t: 11 } ] }, |
|
35 |
- { jobId: 2, operations: [ { t: 20 }, { t: 15 } ] }, |
|
36 |
- { jobId: 3, operations: [ { t: 35 }, { t: 5 } ] }, |
|
37 |
- { jobId: 4, operations: [ { t: 10 }, { t: 31 } ] }, |
|
38 |
- { jobId: 5, operations: [ { t: 18 }, { t: 16 } ] }, |
|
39 |
- { jobId: 6, operations: [ { t: 17 }, { t: 26 } ] }, |
|
40 |
- { jobId: 7, operations: [ { t: 9 }, { t: 32 } ] }, |
|
41 |
- { jobId: 8, operations: [ { t: 44 }, { t: 6 } ] }, |
|
42 |
- { jobId: 9, operations: [ { t: 29 }, { t: 18 } ] }, |
|
43 |
- { jobId: 10, operations: [ { t: 21 }, { t: 22 } ] }, |
|
34 |
+ { jobId: 1, operations: [ { t: 15, name: 'a' }, { t: 11, name: 'b' } ] }, |
|
35 |
+ { jobId: 2, operations: [ { t: 20, name: 'a' }, { t: 15, name: 'b' } ] }, |
|
36 |
+ { jobId: 3, operations: [ { t: 35, name: 'a' }, { t: 5 , name: 'b' } ] }, |
|
37 |
+ { jobId: 4, operations: [ { t: 10, name: 'a' }, { t: 31, name: 'b' } ] }, |
|
38 |
+ { jobId: 5, operations: [ { t: 18, name: 'a' }, { t: 16, name: 'b' } ] }, |
|
39 |
+ { jobId: 6, operations: [ { t: 17, name: 'a' }, { t: 26, name: 'b' } ] }, |
|
40 |
+ { jobId: 7, operations: [ { t: 9, name: 'a' }, { t: 32, name: 'b' } ] }, |
|
41 |
+ { jobId: 8, operations: [ { t: 44, name: 'a' }, { t: 6 , name: 'b' } ] }, |
|
42 |
+ { jobId: 9, operations: [ { t: 29, name: 'a' }, { t: 18, name: 'b' } ] }, |
|
43 |
+ { jobId: 10, operations: [ { t: 21, name: 'a' }, { t: 22, name: 'b' } ] }, |
|
44 | 44 |
]; |
45 | 45 |
|
46 | 46 |
const template = createGantt(jobsWithOperations); |
... | ... |
@@ -49,25 +49,25 @@ test('create gantt', () => { |
49 | 49 |
expect(template[0].length).toBe(10); |
50 | 50 |
expect(template[1].length).toBe(10); |
51 | 51 |
|
52 |
- expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 9 }); |
|
53 |
- expect(template[0][1]).toEqual({ processor: 1, startTime: 9, endTime: 19 }); |
|
54 |
- expect(template[0][2]).toEqual({ processor: 1, startTime: 19, endTime: 36 }); |
|
55 |
- expect(template[0][3]).toEqual({ processor: 1, startTime: 36, endTime: 57 }); |
|
56 |
- expect(template[0][4]).toEqual({ processor: 1, startTime: 57, endTime: 86 }); |
|
57 |
- expect(template[0][5]).toEqual({ processor: 1, startTime: 86, endTime: 104 }); |
|
58 |
- expect(template[0][6]).toEqual({ processor: 1, startTime: 104, endTime: 124 }); |
|
59 |
- expect(template[0][7]).toEqual({ processor: 1, startTime: 124, endTime: 139 }); |
|
60 |
- expect(template[0][8]).toEqual({ processor: 1, startTime: 139, endTime: 183 }); |
|
61 |
- expect(template[0][9]).toEqual({ processor: 1, startTime: 183, endTime: 218 }); |
|
52 |
+ expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 9, name: 'a' }); |
|
53 |
+ expect(template[0][1]).toEqual({ processor: 1, startTime: 9, endTime: 19, name: 'a' }); |
|
54 |
+ expect(template[0][2]).toEqual({ processor: 1, startTime: 19, endTime: 36, name: 'a' }); |
|
55 |
+ expect(template[0][3]).toEqual({ processor: 1, startTime: 36, endTime: 57, name: 'a' }); |
|
56 |
+ expect(template[0][4]).toEqual({ processor: 1, startTime: 57, endTime: 86, name: 'a' }); |
|
57 |
+ expect(template[0][5]).toEqual({ processor: 1, startTime: 86, endTime: 104, name: 'a' }); |
|
58 |
+ expect(template[0][6]).toEqual({ processor: 1, startTime: 104, endTime: 124, name: 'a' }); |
|
59 |
+ expect(template[0][7]).toEqual({ processor: 1, startTime: 124, endTime: 139, name: 'a' }); |
|
60 |
+ expect(template[0][8]).toEqual({ processor: 1, startTime: 139, endTime: 183, name: 'a' }); |
|
61 |
+ expect(template[0][9]).toEqual({ processor: 1, startTime: 183, endTime: 218, name: 'a' }); |
|
62 | 62 |
|
63 |
- expect(template[1][0]).toEqual({ processor: 2, startTime: 9, endTime: 41 }); |
|
64 |
- expect(template[1][1]).toEqual({ processor: 2, startTime: 41, endTime: 72 }); |
|
65 |
- expect(template[1][2]).toEqual({ processor: 2, startTime: 72, endTime: 98 }); |
|
66 |
- expect(template[1][3]).toEqual({ processor: 2, startTime: 98, endTime: 120 }); |
|
67 |
- expect(template[1][4]).toEqual({ processor: 2, startTime: 120, endTime: 138 }); |
|
68 |
- expect(template[1][5]).toEqual({ processor: 2, startTime: 138, endTime: 154 }); |
|
69 |
- expect(template[1][6]).toEqual({ processor: 2, startTime: 154, endTime: 169 }); |
|
70 |
- expect(template[1][7]).toEqual({ processor: 2, startTime: 169, endTime: 180 }); |
|
71 |
- expect(template[1][8]).toEqual({ processor: 2, startTime: 183, endTime: 189 }); |
|
72 |
- expect(template[1][9]).toEqual({ processor: 2, startTime: 218, endTime: 223 }); |
|
63 |
+ expect(template[1][0]).toEqual({ processor: 2, startTime: 9, endTime: 41, name: 'b' }); |
|
64 |
+ expect(template[1][1]).toEqual({ processor: 2, startTime: 41, endTime: 72, name: 'b' }); |
|
65 |
+ expect(template[1][2]).toEqual({ processor: 2, startTime: 72, endTime: 98, name: 'b' }); |
|
66 |
+ expect(template[1][3]).toEqual({ processor: 2, startTime: 98, endTime: 120, name: 'b' }); |
|
67 |
+ expect(template[1][4]).toEqual({ processor: 2, startTime: 120, endTime: 138, name: 'b' }); |
|
68 |
+ expect(template[1][5]).toEqual({ processor: 2, startTime: 138, endTime: 154, name: 'b' }); |
|
69 |
+ expect(template[1][6]).toEqual({ processor: 2, startTime: 154, endTime: 169, name: 'b' }); |
|
70 |
+ expect(template[1][7]).toEqual({ processor: 2, startTime: 169, endTime: 180, name: 'b' }); |
|
71 |
+ expect(template[1][8]).toEqual({ processor: 2, startTime: 183, endTime: 189, name: 'b' }); |
|
72 |
+ expect(template[1][9]).toEqual({ processor: 2, startTime: 218, endTime: 223, name: 'b' }); |
|
73 | 73 |
}); |
74 | 74 |
\ No newline at end of file |
... | ... |
@@ -7,6 +7,7 @@ import { max, remove } from 'ramda'; |
7 | 7 |
|
8 | 8 |
type JobTime = { |
9 | 9 |
jobId: JobId, |
10 |
+ name: string, |
|
10 | 11 |
t: number, |
11 | 12 |
d: number, |
12 | 13 |
w: number, |
... | ... |
@@ -80,7 +81,8 @@ export default (jobs: JobTime[]) => { |
80 | 80 |
processor: 1, |
81 | 81 |
startTime: jobTime.c - jobTime.t, |
82 | 82 |
endTime: jobTime.c, |
83 |
- delayed: max(0, jobTime.c - jobTime.d) |
|
83 |
+ delayed: max(0, jobTime.c - jobTime.d), |
|
84 |
+ name: jobTime.name |
|
84 | 85 |
}), schedule); |
85 | 86 |
|
86 | 87 |
return [normalizedSchedule]; |
... | ... |
@@ -33,32 +33,32 @@ test('create schedule', () => { |
33 | 33 |
|
34 | 34 |
test('create gantt', () => { |
35 | 35 |
const jobs = [ |
36 |
- { jobId: 1, t: 8, d: 11, anc: [], w: 1 }, |
|
37 |
- { jobId: 2, t: 5, d: 9, anc: [], w: 1 }, |
|
38 |
- { jobId: 3, t: 6, d: 10, anc: [], w: 3 }, |
|
39 |
- { jobId: 4, t: 5, d: 14, anc: [1], w: 2 }, |
|
40 |
- { jobId: 5, t: 9, d: 19, anc: [1], w: 1 }, |
|
41 |
- { jobId: 6, t: 3, d: 14, anc: [2, 3, 4], w: 1 }, |
|
42 |
- { jobId: 7, t: 9, d: 36, anc: [2, 3, 4], w: 2 }, |
|
43 |
- { jobId: 8, t: 5, d: 39, anc: [2, 3, 4], w: 2 }, |
|
44 |
- { jobId: 9, t: 8, d: 31, anc: [5, 6], w: 1 }, |
|
45 |
- { jobId: 10, t: 5, d: 59, anc: [7], w: 2 }, |
|
46 |
- { jobId: 11, t: 5, d: 61, anc: [8], w: 3 }, |
|
36 |
+ { jobId: 1, t: 8, d: 11, anc: [], w: 1, name: 'a' }, |
|
37 |
+ { jobId: 2, t: 5, d: 9, anc: [], w: 1, name: 'b' }, |
|
38 |
+ { jobId: 3, t: 6, d: 10, anc: [], w: 3, name: 'c' }, |
|
39 |
+ { jobId: 4, t: 5, d: 14, anc: [1], w: 2, name: 'd' }, |
|
40 |
+ { jobId: 5, t: 9, d: 19, anc: [1], w: 1, name: 'e' }, |
|
41 |
+ { jobId: 6, t: 3, d: 14, anc: [2, 3, 4], w: 1, name: 'f' }, |
|
42 |
+ { jobId: 7, t: 9, d: 36, anc: [2, 3, 4], w: 2, name: 'g' }, |
|
43 |
+ { jobId: 8, t: 5, d: 39, anc: [2, 3, 4], w: 2, name: 'h' }, |
|
44 |
+ { jobId: 9, t: 8, d: 31, anc: [5, 6], w: 1, name: 'i' }, |
|
45 |
+ { jobId: 10, t: 5, d: 59, anc: [7], w: 2, name: 'j' }, |
|
46 |
+ { jobId: 11, t: 5, d: 61, anc: [8], w: 3, name: 'k' }, |
|
47 | 47 |
]; |
48 | 48 |
|
49 | 49 |
const template = createGantt(jobs); |
50 | 50 |
|
51 | 51 |
expect(template.length).toBe(1); |
52 | 52 |
expect(template[0].length).toBe(11); |
53 |
- expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 6, delayed: 0 }); |
|
54 |
- expect(template[0][1]).toEqual({ processor: 1, startTime: 6, endTime: 14, delayed: 3 }); |
|
55 |
- expect(template[0][2]).toEqual({ processor: 1, startTime: 14, endTime: 19, delayed: 5 }); |
|
56 |
- expect(template[0][3]).toEqual({ processor: 1, startTime: 19, endTime: 24, delayed: 15 }); |
|
57 |
- expect(template[0][4]).toEqual({ processor: 1, startTime: 24, endTime: 27, delayed: 13 }); |
|
58 |
- expect(template[0][5]).toEqual({ processor: 1, startTime: 27, endTime: 36, delayed: 17 }); |
|
59 |
- expect(template[0][6]).toEqual({ processor: 1, startTime: 36, endTime: 45, delayed: 9 }); |
|
60 |
- expect(template[0][7]).toEqual({ processor: 1, startTime: 45, endTime: 50, delayed: 11 }); |
|
61 |
- expect(template[0][8]).toEqual({ processor: 1, startTime: 50, endTime: 58, delayed: 27 }); |
|
62 |
- expect(template[0][9]).toEqual({ processor: 1, startTime: 58, endTime: 63, delayed: 2 }); |
|
63 |
- expect(template[0][10]).toEqual({ processor: 1, startTime: 63, endTime: 68, delayed: 9 }); |
|
53 |
+ expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 6, delayed: 0, name: 'c' }); |
|
54 |
+ expect(template[0][1]).toEqual({ processor: 1, startTime: 6, endTime: 14, delayed: 3, name: 'a' }); |
|
55 |
+ expect(template[0][2]).toEqual({ processor: 1, startTime: 14, endTime: 19, delayed: 5, name: 'd' }); |
|
56 |
+ expect(template[0][3]).toEqual({ processor: 1, startTime: 19, endTime: 24, delayed: 15, name: 'b' }); |
|
57 |
+ expect(template[0][4]).toEqual({ processor: 1, startTime: 24, endTime: 27, delayed: 13, name: 'f' }); |
|
58 |
+ expect(template[0][5]).toEqual({ processor: 1, startTime: 27, endTime: 36, delayed: 17, name: 'e' }); |
|
59 |
+ expect(template[0][6]).toEqual({ processor: 1, startTime: 36, endTime: 45, delayed: 9, name: 'g' }); |
|
60 |
+ expect(template[0][7]).toEqual({ processor: 1, startTime: 45, endTime: 50, delayed: 11, name: 'h' }); |
|
61 |
+ expect(template[0][8]).toEqual({ processor: 1, startTime: 50, endTime: 58, delayed: 27, name: 'i' }); |
|
62 |
+ expect(template[0][9]).toEqual({ processor: 1, startTime: 58, endTime: 63, delayed: 2, name: 'k' }); |
|
63 |
+ expect(template[0][10]).toEqual({ processor: 1, startTime: 63, endTime: 68, delayed: 9, name: 'j' }); |
|
64 | 64 |
}); |
65 | 65 |
\ No newline at end of file |
... | ... |
@@ -4,7 +4,8 @@ import { groupBy, max } from 'ramda'; |
4 | 4 |
|
5 | 5 |
type JobTime = { |
6 | 6 |
jobId: JobId, |
7 |
- t: number |
|
7 |
+ t: number, |
|
8 |
+ name: string |
|
8 | 9 |
}; |
9 | 10 |
|
10 | 11 |
type JobTimeAssigned = JobTime | { |
... | ... |
@@ -74,6 +75,7 @@ export default (jobs: JobTime[], processorCount: number) => { |
74 | 74 |
return map(map((job: JobTimeAssignedWithC) => ({ |
75 | 75 |
processor: job.processor, |
76 | 76 |
startTime: job.c - job.t, |
77 |
- endTime: job.c |
|
77 |
+ endTime: job.c, |
|
78 |
+ name: job.name |
|
78 | 79 |
})), grouped); |
79 | 80 |
}; |
80 | 81 |
\ No newline at end of file |
... | ... |
@@ -23,11 +23,11 @@ test('create schedule', () => { |
23 | 23 |
|
24 | 24 |
test('create gantt', () => { |
25 | 25 |
const jobs = [ |
26 |
- { jobId: 1, t: 3 }, |
|
27 |
- { jobId: 2, t: 9 }, |
|
28 |
- { jobId: 3, t: 5 }, |
|
29 |
- { jobId: 4, t: 7 }, |
|
30 |
- { jobId: 5, t: 6 }, |
|
26 |
+ { jobId: 1, t: 3, name: 'a' }, |
|
27 |
+ { jobId: 2, t: 9, name: 'b' }, |
|
28 |
+ { jobId: 3, t: 5, name: 'c' }, |
|
29 |
+ { jobId: 4, t: 7, name: 'd' }, |
|
30 |
+ { jobId: 5, t: 6, name: 'e' }, |
|
31 | 31 |
]; |
32 | 32 |
|
33 | 33 |
const template = createGantt(jobs, 3); |
... | ... |
@@ -36,11 +36,11 @@ test('create gantt', () => { |
36 | 36 |
expect(template[0].length).toBe(2); |
37 | 37 |
expect(template[1].length).toBe(3); |
38 | 38 |
expect(template[2].length).toBe(2); |
39 |
- expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 3 }); |
|
40 |
- expect(template[0][1]).toEqual({ processor: 1, startTime: 3, endTime: 10 }); |
|
41 |
- expect(template[1][0]).toEqual({ processor: 2, startTime: 0, endTime: 2 }); |
|
42 |
- expect(template[1][1]).toEqual({ processor: 2, startTime: 2, endTime: 7 }); |
|
43 |
- expect(template[1][2]).toEqual({ processor: 2, startTime: 7, endTime: 10 }); |
|
44 |
- expect(template[2][0]).toEqual({ processor: 3, startTime: 0, endTime: 4 }); |
|
45 |
- expect(template[2][1]).toEqual({ processor: 3, startTime: 4, endTime: 10 }); |
|
39 |
+ expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 3 , name: 'a'}); |
|
40 |
+ expect(template[0][1]).toEqual({ processor: 1, startTime: 3, endTime: 10, name: 'b' }); |
|
41 |
+ expect(template[1][0]).toEqual({ processor: 2, startTime: 0, endTime: 2 , name: 'b'}); |
|
42 |
+ expect(template[1][1]).toEqual({ processor: 2, startTime: 2, endTime: 7 , name: 'c'}); |
|
43 |
+ expect(template[1][2]).toEqual({ processor: 2, startTime: 7, endTime: 10, name: 'd' }); |
|
44 |
+ expect(template[2][0]).toEqual({ processor: 3, startTime: 0, endTime: 4 , name: 'd'}); |
|
45 |
+ expect(template[2][1]).toEqual({ processor: 3, startTime: 4, endTime: 10, name: 'e' }); |
|
46 | 46 |
}); |
47 | 47 |
\ No newline at end of file |
... | ... |
@@ -6,6 +6,7 @@ type JobTime = { |
6 | 6 |
jobId: JobId, |
7 | 7 |
t: number, |
8 | 8 |
d: number, |
9 |
+ name: string |
|
9 | 10 |
}; |
10 | 11 |
|
11 | 12 |
const findLateJob = (jobTimes: JobTime[]) => |
... | ... |
@@ -68,7 +69,8 @@ export default (jobs: JobTime[]) => { |
68 | 68 |
processor: 1, |
69 | 69 |
startTime: jobTime.c - jobTime.t, |
70 | 70 |
endTime: jobTime.c, |
71 |
- delayed: max(0, jobTime.c - jobTime.d) |
|
71 |
+ delayed: max(0, jobTime.c - jobTime.d), |
|
72 |
+ name: jobTime.name |
|
72 | 73 |
}), schedule); |
73 | 74 |
|
74 | 75 |
return [normalizedSchedule]; |
... | ... |
@@ -29,28 +29,28 @@ test('create schedule', () => { |
29 | 29 |
|
30 | 30 |
test('create gantt', () => { |
31 | 31 |
const jobs = [ |
32 |
- { jobId: 1, t: 6, d: 10 }, |
|
33 |
- { jobId: 2, t: 8, d: 25 }, |
|
34 |
- { jobId: 3, t: 4, d: 20 }, |
|
35 |
- { jobId: 4, t: 6, d: 18 }, |
|
36 |
- { jobId: 5, t: 7, d: 20 }, |
|
37 |
- { jobId: 6, t: 4, d: 40 }, |
|
38 |
- { jobId: 7, t: 3, d: 35 }, |
|
39 |
- { jobId: 8, t: 6, d: 42 }, |
|
40 |
- { jobId: 9, t: 5, d: 25 }, |
|
32 |
+ { jobId: 1, t: 6, d: 10, name: 'a' }, |
|
33 |
+ { jobId: 2, t: 8, d: 25, name: 'b' }, |
|
34 |
+ { jobId: 3, t: 4, d: 20, name: 'c' }, |
|
35 |
+ { jobId: 4, t: 6, d: 18, name: 'd' }, |
|
36 |
+ { jobId: 5, t: 7, d: 20, name: 'e' }, |
|
37 |
+ { jobId: 6, t: 4, d: 40, name: 'f' }, |
|
38 |
+ { jobId: 7, t: 3, d: 35, name: 'g' }, |
|
39 |
+ { jobId: 8, t: 6, d: 42, name: 'h' }, |
|
40 |
+ { jobId: 9, t: 5, d: 25, name: 'i' }, |
|
41 | 41 |
]; |
42 | 42 |
|
43 | 43 |
const template = createGantt(jobs); |
44 | 44 |
|
45 | 45 |
expect(template.length).toBe(1); |
46 | 46 |
expect(template[0].length).toBe(9); |
47 |
- expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 6, delayed: 0 }); |
|
48 |
- expect(template[0][1]).toEqual({ processor: 1, startTime: 6, endTime: 12, delayed: 0 }); |
|
49 |
- expect(template[0][2]).toEqual({ processor: 1, startTime: 12, endTime: 16, delayed: 0 }); |
|
50 |
- expect(template[0][3]).toEqual({ processor: 1, startTime: 16, endTime: 21, delayed: 0 }); |
|
51 |
- expect(template[0][4]).toEqual({ processor: 1, startTime: 21, endTime: 24, delayed: 0 }); |
|
52 |
- expect(template[0][5]).toEqual({ processor: 1, startTime: 24, endTime: 28, delayed: 0 }); |
|
53 |
- expect(template[0][6]).toEqual({ processor: 1, startTime: 28, endTime: 34, delayed: 0 }); |
|
54 |
- expect(template[0][7]).toEqual({ processor: 1, startTime: 34, endTime: 41, delayed: 21 }); |
|
55 |
- expect(template[0][8]).toEqual({ processor: 1, startTime: 41, endTime: 49, delayed: 24 }); |
|
47 |
+ expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 6, delayed: 0, name: 'a' }); |
|
48 |
+ expect(template[0][1]).toEqual({ processor: 1, startTime: 6, endTime: 12, delayed: 0, name: 'd' }); |
|
49 |
+ expect(template[0][2]).toEqual({ processor: 1, startTime: 12, endTime: 16, delayed: 0, name: 'c' }); |
|
50 |
+ expect(template[0][3]).toEqual({ processor: 1, startTime: 16, endTime: 21, delayed: 0, name: 'i' }); |
|
51 |
+ expect(template[0][4]).toEqual({ processor: 1, startTime: 21, endTime: 24, delayed: 0, name: 'g' }); |
|
52 |
+ expect(template[0][5]).toEqual({ processor: 1, startTime: 24, endTime: 28, delayed: 0, name: 'f' }); |
|
53 |
+ expect(template[0][6]).toEqual({ processor: 1, startTime: 28, endTime: 34, delayed: 0, name: 'h' }); |
|
54 |
+ expect(template[0][7]).toEqual({ processor: 1, startTime: 34, endTime: 41, delayed: 21, name: 'e' }); |
|
55 |
+ expect(template[0][8]).toEqual({ processor: 1, startTime: 41, endTime: 49, delayed: 24, name: 'b' }); |
|
56 | 56 |
}); |
57 | 57 |
\ No newline at end of file |
... | ... |
@@ -7,16 +7,16 @@ import { fillCorrupted } from '../campbel'; |
7 | 7 |
|
8 | 8 |
type JobOperations = { |
9 | 9 |
jobId: JobId, |
10 |
- operations: Array<{ t: number }> |
|
10 |
+ operations: Array<{ t: number, name: string }> |
|
11 | 11 |
}; |
12 | 12 |
|
13 | 13 |
type JobOperationsWithC = { |
14 | 14 |
jobId: JobId, |
15 |
- operations: Array<{ t: number, c: number }> |
|
15 |
+ operations: Array<{ t: number, c: number, name: string }> |
|
16 | 16 |
}; |
17 | 17 |
|
18 | 18 |
export const createSchedule = (jobsOperations: JobOperations[], processorsCount: number): JobOperationsWithC[] => { |
19 |
- jobsOperations = fillCorrupted(jobsOperations); |
|
19 |
+ jobsOperations = fillCorrupted(jobsOperations, processorsCount); |
|
20 | 20 |
|
21 | 21 |
const jobsOperationsWithKoefs = map(jobsOperation => { |
22 | 22 |
const koef = reduce( |
... | ... |
@@ -48,6 +48,7 @@ export default (jobsOperations: JobOperations[], processorsCount: number) => { |
48 | 48 |
processor: i + 1, |
49 | 49 |
startTime: jobTime.operations[i].c - jobTime.operations[i].t, |
50 | 50 |
endTime: jobTime.operations[i].c, |
51 |
+ name: jobTime.operations[i].name |
|
51 | 52 |
}), schedule) |
52 | 53 |
, processorsCount); |
53 | 54 |
}; |
54 | 55 |
\ No newline at end of file |
... | ... |
@@ -27,14 +27,14 @@ test('create schedule', () => { |
27 | 27 |
|
28 | 28 |
test('create gantt', () => { |
29 | 29 |
const jobsWithOperations = [ |
30 |
- { jobId: 1, operations: [ { t: 12 }, { t: 8 }, { t: 11 } ] }, |
|
31 |
- { jobId: 2, operations: [ { t: 6 }, { t: 13 }, { t: 19 } ] }, |
|
32 |
- { jobId: 3, operations: [ { t: 15 }, { t: 10 }, { t: 18 } ] }, |
|
33 |
- { jobId: 4, operations: [ { t: 16 }, { t: 7 }, { t: 21 } ] }, |
|
34 |
- { jobId: 5, operations: [ { t: 4 }, { t: 4 }, { t: 20 } ] }, |
|
35 |
- { jobId: 6, operations: [ { t: 3 }, { t: 12 }, { t: 13 } ] }, |
|
36 |
- { jobId: 7, operations: [ { t: 17 }, { t: 6 }, { t: 8 } ] }, |
|
37 |
- { jobId: 8, operations: [ { t: 10 }, { t: 2 }, { t: 25 } ] }, |
|
30 |
+ { jobId: 1, operations: [ { t: 12, name: 'a' }, { t: 8 , name: 'b' }, { t: 11, name: 'c' } ] }, |
|
31 |
+ { jobId: 2, operations: [ { t: 6, name: 'a' }, { t: 13, name: 'b' }, { t: 19, name: 'c' } ] }, |
|
32 |
+ { jobId: 3, operations: [ { t: 15, name: 'a' }, { t: 10, name: 'b' }, { t: 18, name: 'c' } ] }, |
|
33 |
+ { jobId: 4, operations: [ { t: 16, name: 'a' }, { t: 7 , name: 'b' }, { t: 21, name: 'c' } ] }, |
|
34 |
+ { jobId: 5, operations: [ { t: 4, name: 'a' }, { t: 4 , name: 'b' }, { t: 20, name: 'c' } ] }, |
|
35 |
+ { jobId: 6, operations: [ { t: 3, name: 'a' }, { t: 12, name: 'b' }, { t: 13, name: 'c' } ] }, |
|
36 |
+ { jobId: 7, operations: [ { t: 17, name: 'a' }, { t: 6 , name: 'b' }, { t: 8, name: 'c' } ] }, |
|
37 |
+ { jobId: 8, operations: [ { t: 10, name: 'a' }, { t: 2 , name: 'b' }, { t: 25, name: 'c' } ] }, |
|
38 | 38 |
]; |
39 | 39 |
|
40 | 40 |
const template = createGantt(jobsWithOperations, 3); |
... | ... |
@@ -44,30 +44,30 @@ test('create gantt', () => { |
44 | 44 |
expect(template[1].length).toBe(8); |
45 | 45 |
expect(template[2].length).toBe(8); |
46 | 46 |
|
47 |
- expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 16 }); |
|
48 |
- expect(template[0][1]).toEqual({ processor: 1, startTime: 16, endTime: 26 }); |
|
49 |
- expect(template[0][2]).toEqual({ processor: 1, startTime: 26, endTime: 41 }); |
|
50 |
- expect(template[0][3]).toEqual({ processor: 1, startTime: 41, endTime: 47 }); |
|
51 |
- expect(template[0][4]).toEqual({ processor: 1, startTime: 47, endTime: 64 }); |
|
52 |
- expect(template[0][5]).toEqual({ processor: 1, startTime: 64, endTime: 68 }); |
|
53 |
- expect(template[0][6]).toEqual({ processor: 1, startTime: 68, endTime: 80 }); |
|
54 |
- expect(template[0][7]).toEqual({ processor: 1, startTime: 80, endTime: 83 }); |
|
47 |
+ expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 16, name: 'a' }); |
|
48 |
+ expect(template[0][1]).toEqual({ processor: 1, startTime: 16, endTime: 26, name: 'a' }); |
|
49 |
+ expect(template[0][2]).toEqual({ processor: 1, startTime: 26, endTime: 41, name: 'a' }); |
|
50 |
+ expect(template[0][3]).toEqual({ processor: 1, startTime: 41, endTime: 47, name: 'a' }); |
|
51 |
+ expect(template[0][4]).toEqual({ processor: 1, startTime: 47, endTime: 64, name: 'a' }); |
|
52 |
+ expect(template[0][5]).toEqual({ processor: 1, startTime: 64, endTime: 68, name: 'a' }); |
|
53 |
+ expect(template[0][6]).toEqual({ processor: 1, startTime: 68, endTime: 80, name: 'a' }); |
|
54 |
+ expect(template[0][7]).toEqual({ processor: 1, startTime: 80, endTime: 83, name: 'a' }); |
|
55 | 55 |
|
56 |
- expect(template[1][0]).toEqual({ processor: 2, startTime: 16, endTime: 23 }); |
|
57 |
- expect(template[1][1]).toEqual({ processor: 2, startTime: 26, endTime: 28 }); |
|
58 |
- expect(template[1][2]).toEqual({ processor: 2, startTime: 41, endTime: 51 }); |
|
59 |
- expect(template[1][3]).toEqual({ processor: 2, startTime: 51, endTime: 64 }); |
|
60 |
- expect(template[1][4]).toEqual({ processor: 2, startTime: 64, endTime: 70 }); |
|
61 |
- expect(template[1][5]).toEqual({ processor: 2, startTime: 70, endTime: 74 }); |
|
62 |
- expect(template[1][6]).toEqual({ processor: 2, startTime: 80, endTime: 88 }); |
|
63 |
- expect(template[1][7]).toEqual({ processor: 2, startTime: 88, endTime: 100 }); |
|
56 |
+ expect(template[1][0]).toEqual({ processor: 2, startTime: 16, endTime: 23, name: 'b' }); |
|
57 |
+ expect(template[1][1]).toEqual({ processor: 2, startTime: 26, endTime: 28, name: 'b' }); |
|
58 |
+ expect(template[1][2]).toEqual({ processor: 2, startTime: 41, endTime: 51, name: 'b' }); |
|
59 |
+ expect(template[1][3]).toEqual({ processor: 2, startTime: 51, endTime: 64, name: 'b' }); |
|
60 |
+ expect(template[1][4]).toEqual({ processor: 2, startTime: 64, endTime: 70, name: 'b' }); |
|
61 |
+ expect(template[1][5]).toEqual({ processor: 2, startTime: 70, endTime: 74, name: 'b' }); |
|
62 |
+ expect(template[1][6]).toEqual({ processor: 2, startTime: 80, endTime: 88, name: 'b' }); |
|
63 |
+ expect(template[1][7]).toEqual({ processor: 2, startTime: 88, endTime: 100, name: 'b' }); |
|
64 | 64 |
|
65 |
- expect(template[2][0]).toEqual({ processor: 3, startTime: 23, endTime: 44 }); |
|
66 |
- expect(template[2][1]).toEqual({ processor: 3, startTime: 44, endTime: 69 }); |
|
67 |
- expect(template[2][2]).toEqual({ processor: 3, startTime: 69, endTime: 87 }); |
|
68 |
- expect(template[2][3]).toEqual({ processor: 3, startTime: 87, endTime: 106 }); |
|
69 |
- expect(template[2][4]).toEqual({ processor: 3, startTime: 106, endTime: 114 }); |
|
70 |
- expect(template[2][5]).toEqual({ processor: 3, startTime: 114, endTime: 134 }); |
|
71 |
- expect(template[2][6]).toEqual({ processor: 3, startTime: 134, endTime: 145 }); |
|
72 |
- expect(template[2][7]).toEqual({ processor: 3, startTime: 145, endTime: 158 }); |
|
65 |
+ expect(template[2][0]).toEqual({ processor: 3, startTime: 23, endTime: 44, name: 'c' }); |
|
66 |
+ expect(template[2][1]).toEqual({ processor: 3, startTime: 44, endTime: 69, name: 'c' }); |
|
67 |
+ expect(template[2][2]).toEqual({ processor: 3, startTime: 69, endTime: 87, name: 'c' }); |
|
68 |
+ expect(template[2][3]).toEqual({ processor: 3, startTime: 87, endTime: 106, name: 'c' }); |
|
69 |
+ expect(template[2][4]).toEqual({ processor: 3, startTime: 106, endTime: 114, name: 'c' }); |
|
70 |
+ expect(template[2][5]).toEqual({ processor: 3, startTime: 114, endTime: 134, name: 'c' }); |
|
71 |
+ expect(template[2][6]).toEqual({ processor: 3, startTime: 134, endTime: 145, name: 'c' }); |
|
72 |
+ expect(template[2][7]).toEqual({ processor: 3, startTime: 145, endTime: 158, name: 'c' }); |
|
73 | 73 |
}); |
74 | 74 |
\ No newline at end of file |
... | ... |
@@ -9,6 +9,7 @@ type JobTime = { |
9 | 9 |
jobId: JobId, |
10 | 10 |
t: number, |
11 | 11 |
d: number, |
12 |
+ name: string |
|
12 | 13 |
}; |
13 | 14 |
|
14 | 15 |
const findMaxTJob = (jobTimes: JobTime[]) => |
... | ... |
@@ -65,7 +66,8 @@ export default (jobs: JobTime[]) => { |
65 | 65 |
processor: 1, |
66 | 66 |
startTime: jobTime.c - jobTime.t, |
67 | 67 |
endTime: jobTime.c, |
68 |
- delayed: max(0, jobTime.c - jobTime.d) |
|
68 |
+ delayed: max(0, jobTime.c - jobTime.d), |
|
69 |
+ name: jobTime.name |
|
69 | 70 |
}), schedule); |
70 | 71 |
|
71 | 72 |
return [normalizedSchedule]; |
... | ... |
@@ -33,32 +33,32 @@ test('create schedule', () => { |
33 | 33 |
|
34 | 34 |
test('create gantt', () => { |
35 | 35 |
const jobs = [ |
36 |
- { jobId: 1, t: 4, d: 10 }, |
|
37 |
- { jobId: 2, t: 6, d: 25 }, |
|
38 |
- { jobId: 3, t: 4, d: 20 }, |
|
39 |
- { jobId: 4, t: 6, d: 18 }, |
|
40 |
- { jobId: 5, t: 7, d: 40 }, |
|
41 |
- { jobId: 6, t: 4, d: 50 }, |
|
42 |
- { jobId: 7, t: 3, d: 35 }, |
|
43 |
- { jobId: 8, t: 2, d: 52 }, |
|
44 |
- { jobId: 9, t: 6, d: 46 }, |
|
45 |
- { jobId: 10, t: 7, d: 28 }, |
|
46 |
- { jobId: 11, t: 1, d: 50 }, |
|
36 |
+ { jobId: 1, t: 4, d: 10, name: 'a' }, |
|
37 |
+ { jobId: 2, t: 6, d: 25, name: 'b' }, |
|
38 |
+ { jobId: 3, t: 4, d: 20, name: 'c' }, |
|
39 |
+ { jobId: 4, t: 6, d: 18, name: 'd' }, |
|
40 |
+ { jobId: 5, t: 7, d: 40, name: 'e' }, |
|
41 |
+ { jobId: 6, t: 4, d: 50, name: 'f' }, |
|
42 |
+ { jobId: 7, t: 3, d: 35, name: 'g' }, |
|
43 |
+ { jobId: 8, t: 2, d: 52, name: 'h' }, |
|
44 |
+ { jobId: 9, t: 6, d: 46, name: 'i' }, |
|
45 |
+ { jobId: 10, t: 7, d: 28, name: 'j' }, |
|
46 |
+ { jobId: 11, t: 1, d: 50, name: 'k' }, |
|
47 | 47 |
]; |
48 | 48 |
|
49 | 49 |
const template = createGantt(jobs); |
50 | 50 |
|
51 | 51 |
expect(template.length).toBe(1); |
52 | 52 |
expect(template[0].length).toBe(11); |
53 |
- expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 1, delayed: 0 }); |
|
54 |
- expect(template[0][1]).toEqual({ processor: 1, startTime: 1, endTime: 5, delayed: 0 }); |
|
55 |
- expect(template[0][2]).toEqual({ processor: 1, startTime: 5, endTime: 9, delayed: 0 }); |
|
56 |
- expect(template[0][3]).toEqual({ processor: 1, startTime: 9, endTime: 15, delayed: 0 }); |
|
57 |
- expect(template[0][4]).toEqual({ processor: 1, startTime: 15, endTime: 21, delayed: 0 }); |
|
58 |
- expect(template[0][5]).toEqual({ processor: 1, startTime: 21, endTime: 28, delayed: 0 }); |
|
59 |
- expect(template[0][6]).toEqual({ processor: 1, startTime: 28, endTime: 30, delayed: 0 }); |
|
60 |
- expect(template[0][7]).toEqual({ processor: 1, startTime: 30, endTime: 33, delayed: 0 }); |
|
61 |
- expect(template[0][8]).toEqual({ processor: 1, startTime: 33, endTime: 40, delayed: 0 }); |
|
62 |
- expect(template[0][9]).toEqual({ processor: 1, startTime: 40, endTime: 46, delayed: 0 }); |
|
63 |
- expect(template[0][10]).toEqual({ processor: 1, startTime: 46, endTime: 50, delayed: 0 }); |
|
53 |
+ expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 1, delayed: 0, name: 'k' }); |
|
54 |
+ expect(template[0][1]).toEqual({ processor: 1, startTime: 1, endTime: 5, delayed: 0, name: 'c' }); |
|
55 |
+ expect(template[0][2]).toEqual({ processor: 1, startTime: 5, endTime: 9, delayed: 0, name: 'a' }); |
|
56 |
+ expect(template[0][3]).toEqual({ processor: 1, startTime: 9, endTime: 15, delayed: 0, name: 'd' }); |
|
57 |
+ expect(template[0][4]).toEqual({ processor: 1, startTime: 15, endTime: 21, delayed: 0, name: 'b' }); |
|
58 |
+ expect(template[0][5]).toEqual({ processor: 1, startTime: 21, endTime: 28, delayed: 0, name: 'j' }); |
|
59 |
+ expect(template[0][6]).toEqual({ processor: 1, startTime: 28, endTime: 30, delayed: 0, name: 'h' }); |
|
60 |
+ expect(template[0][7]).toEqual({ processor: 1, startTime: 30, endTime: 33, delayed: 0, name: 'g' }); |
|
61 |
+ expect(template[0][8]).toEqual({ processor: 1, startTime: 33, endTime: 40, delayed: 0, name: 'e' }); |
|
62 |
+ expect(template[0][9]).toEqual({ processor: 1, startTime: 40, endTime: 46, delayed: 0, name: 'i' }); |
|
63 |
+ expect(template[0][10]).toEqual({ processor: 1, startTime: 46, endTime: 50, delayed: 0, name: 'f' }); |
|
64 | 64 |
}); |
65 | 65 |
\ No newline at end of file |
... | ... |
@@ -17,6 +17,7 @@ import { updateCTime } from '../mcnaught'; |
17 | 17 |
type JobTime = { |
18 | 18 |
jobId: JobId, |
19 | 19 |
t: number, |
20 |
+ name: string, |
|
20 | 21 |
anc: JobId[] |
21 | 22 |
}; |
22 | 23 |
|
... | ... |
@@ -124,6 +125,7 @@ export default (jobTimes: JobTime[], processorsCount: number) => { |
124 | 124 |
return map(map(job => ({ |
125 | 125 |
processor: job.processor, |
126 | 126 |
startTime: job.c - job.t, |
127 |
- endTime: job.c |
|
127 |
+ endTime: job.c, |
|
128 |
+ name: job.name |
|
128 | 129 |
})), grouped); |
129 | 130 |
}; |
130 | 131 |
\ No newline at end of file |
... | ... |
@@ -48,13 +48,13 @@ test('create schedule 2', () => { |
48 | 48 |
|
49 | 49 |
test('create gantt', () => { |
50 | 50 |
const jobsWithOperations = [ |
51 |
- { jobId: 1, t: 4, anc: [] }, |
|
52 |
- { jobId: 2, t: 6, anc: [1] }, |
|
53 |
- { jobId: 3, t: 7, anc: [1] }, |
|
54 |
- { jobId: 4, t: 6, anc: [1] }, |
|
55 |
- { jobId: 5, t: 4, anc: [2, 3] }, |
|
56 |
- { jobId: 6, t: 7, anc: [4, 5] }, |
|
57 |
- { jobId: 7, t: 2, anc: [2, 4, 6] }, |
|
51 |
+ { jobId: 1, t: 4, anc: [], name: 'a' }, |
|
52 |
+ { jobId: 2, t: 6, anc: [1], name: 'b' }, |
|
53 |
+ { jobId: 3, t: 7, anc: [1], name: 'c' }, |
|
54 |
+ { jobId: 4, t: 6, anc: [1], name: 'd' }, |
|
55 |
+ { jobId: 5, t: 4, anc: [2, 3], name: 'e' }, |
|
56 |
+ { jobId: 6, t: 7, anc: [4, 5], name: 'f' }, |
|
57 |
+ { jobId: 7, t: 2, anc: [2, 4, 6], name: 'g' }, |
|
58 | 58 |
]; |
59 | 59 |
|
60 | 60 |
const template = createGantt(jobsWithOperations, 3); |
... | ... |
@@ -64,13 +64,13 @@ test('create gantt', () => { |
64 | 64 |
expect(template[1].length).toBe(2); |
65 | 65 |
expect(template[2].length).toBe(3); |
66 | 66 |
|
67 |
- expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 4 }); |
|
68 |
- expect(template[0][1]).toEqual({ processor: 1, startTime: 4, endTime: 10 }); |
|
67 |
+ expect(template[0][0]).toEqual({ processor: 1, startTime: 0, endTime: 4, name: 'a' }); |
|
68 |
+ expect(template[0][1]).toEqual({ processor: 1, startTime: 4, endTime: 10, name: 'b' }); |
|
69 | 69 |
|
70 |
- expect(template[1][0]).toEqual({ processor: 2, startTime: 0, endTime: 7 }); |
|
71 |
- expect(template[1][1]).toEqual({ processor: 2, startTime: 7, endTime: 13 }); |
|
70 |
+ expect(template[1][0]).toEqual({ processor: 2, startTime: 0, endTime: 7, name: 'c' }); |
|
71 |
+ expect(template[1][1]).toEqual({ processor: 2, startTime: 7, endTime: 13, name: 'd' }); |
|
72 | 72 |
|
73 |
- expect(template[2][0]).toEqual({ processor: 3, startTime: 0, endTime: 4 }); |
|
74 |
- expect(template[2][1]).toEqual({ processor: 3, startTime: 4, endTime: 11 }); |
|
75 |
- expect(template[2][2]).toEqual({ processor: 3, startTime: 11, endTime: 13 }); |
|
73 |
+ expect(template[2][0]).toEqual({ processor: 3, startTime: 0, endTime: 4, name: 'e' }); |
|
74 |
+ expect(template[2][1]).toEqual({ processor: 3, startTime: 4, endTime: 11, name: 'f' }); |
|
75 |
+ expect(template[2][2]).toEqual({ processor: 3, startTime: 11, endTime: 13, name: 'g' }); |
|
76 | 76 |
}); |
77 | 77 |
\ No newline at end of file |
... | ... |
@@ -42,6 +42,7 @@ class Form extends React.PureComponent { |
42 | 42 |
// } |
43 | 43 |
], |
44 | 44 |
preempt: false, |
45 |
+ flowShop: '0' |
|
45 | 46 |
}; |
46 | 47 |
|
47 | 48 |
onSubmit = (values) => { |
... | ... |
@@ -74,9 +75,9 @@ class Form extends React.PureComponent { |
74 | 74 |
|
75 | 75 |
render() { |
76 | 76 |
return ( |
77 |
- <Formik initialValues={this.state} onSubmit={this.onSubmit} render={({ setFieldValue, values: { rows, allJobs } }) => ( |
|
77 |
+ <Formik initialValues={this.state} onSubmit={this.onSubmit} render={({ setFieldValue, values: { rows, allJobs, flowShop } }) => ( |
|
78 | 78 |
<FormikForm> |
79 |
- <h1>1/3 Vytvorenie pracovníkov</h1> |
|
79 |
+ <h1>1/3 Vytvorenie úloh</h1> |
|
80 | 80 |
<Box flexWrap="wrap" flexDirection="row"> |
81 | 81 |
{allJobs.map((_, key) => ( |
82 | 82 |
<Box key={key} width={300} flexDirection="row" marginBottom={10}> |
... | ... |
@@ -87,7 +88,7 @@ class Form extends React.PureComponent { |
87 | 87 |
</Box> |
88 | 88 |
|
89 | 89 |
<Box width={300} flexDirection="row" marginBottom={10}> |
90 |
- <Box as="input" placeholder="Nový pracovník" onKeyDown={this.addTemplateWorker(setFieldValue, allJobs)} nativeRef={c => this.new = c} marginRight={5} flex={1} /> |
|
90 |
+ <Box as="input" placeholder="Nová úloha" onKeyDown={this.addTemplateWorker(setFieldValue, allJobs)} nativeRef={c => this.new = c} marginRight={5} flex={1} /> |
|
91 | 91 |
<Box cursor="pointer" onClick={this.addTemplateWorker(setFieldValue, allJobs)} color="green" fontSize="1rem">+</Box> |
92 | 92 |
</Box> |
93 | 93 |
|
... | ... |
@@ -98,7 +99,7 @@ class Form extends React.PureComponent { |
98 | 98 |
{rows.length ? |
99 | 99 |
<Box flexDirection="row" marginBottom={10}> |
100 | 100 |
<Box flexBasis="20%" flexShrink={0}><strong>Pracovníci</strong></Box> |
101 |
- <Box flexBasis="63%" flexShrink={0}><strong>Úlohy</strong></Box> |
|
101 |
+ <Box flexBasis="63%" flexShrink={0}><strong>Priradené úlohy</strong></Box> |
|
102 | 102 |
</Box> : null |
103 | 103 |
} |
104 | 104 |
|
... | ... |
@@ -121,8 +122,24 @@ class Form extends React.PureComponent { |
121 | 121 |
|
122 | 122 |
{rows.length ? |
123 | 123 |
<div> |
124 |
+ <Box flexDirection="row" justifyContent="center" marginBottom={10}> |
|
125 |
+ <Box as="label" justifyContent="center" flexDirection="row" marginRight={5}> |
|
126 |
+ <Field type="radio" name="flowShop" value="1" checked={flowShop == '1'} disabled={rows.length === 1} /> |
|
127 |
+ <Box as="em" color="gray" textAlign="center" fontSize="0.9em"> |
|
128 |
+ Flow shop |
|
129 |
+ </Box> |
|
130 |
+ </Box> |
|
131 |
+ |
|
132 |
+ <Box as="label" justifyContent="center" flexDirection="row"> |
|
133 |
+ <Field type="radio" name="flowShop" value="0" checked={flowShop == '0'} disabled={rows.length === 1} /> |
|
134 |
+ <Box as="em" color="gray" textAlign="center" fontSize="0.9em"> |
|
135 |
+ Pracovníci zvládnu každú úlohu |
|
136 |
+ </Box> |
|
137 |
+ </Box> |
|
138 |
+ </Box> |
|
139 |
+ |
|
124 | 140 |
<Box as="label" justifyContent="center" flexDirection="row"> |
125 |
- <Field type="checkbox" name="preempt"/> |
|
141 |
+ <Field type="checkbox" name="preempt" disabled={flowShop == '1' || rows.length === 1}/> |
|
126 | 142 |
<Box as="em" color="gray" textAlign="center" fontSize="0.9em"> |
127 | 143 |
Úlohy pracovníkov možno prerušiť |
128 | 144 |
</Box> |
... | ... |
@@ -174,7 +191,7 @@ const SortableJob = SortableElement( |
174 | 174 |
|
175 | 175 |
render() { |
176 | 176 |
const { prefix, job, existingJobs: _existingJobs } = this.props; |
177 |
- const { formik: { values: { rows, allJobs } } } = this.context; |
|
177 |
+ const { formik: { values: { rows, allJobs, flowShop } } } = this.context; |
|
178 | 178 |
|
179 | 179 |
const existingJobs = map( |
180 | 180 |
value => { |
... | ... |
@@ -200,9 +217,11 @@ const SortableJob = SortableElement( |
200 | 200 |
paddingBottom={10} |
201 | 201 |
className="sortable-inactive" |
202 | 202 |
> |
203 |
- <Box marginRight={10} fontSize="1.5rem" width={20}> |
|
204 |
- <DragHandle/> |
|
205 |
- </Box> |
|
203 |
+ {flowShop == '1' ? |
|
204 |
+ <Box marginRight={10} fontSize="1.5rem" width={20}> |
|
205 |
+ <DragHandle/> |
|
206 |
+ </Box> |
|
207 |
+ : null} |
|
206 | 208 |
|
207 | 209 |
<Box flex={1} padding={1}> |
208 | 210 |
<Box width={200} marginBottom={10} flexDirection="row"> |
... | ... |
@@ -11,11 +11,20 @@ class Gannt extends React.PureComponent { |
11 | 11 |
super(props); |
12 | 12 |
|
13 | 13 |
this.state = { |
14 |
- startTime: minTime(props.data), |
|
14 |
+ startTime: 0, |
|
15 | 15 |
endTime: maxTime(props.data) |
16 | 16 |
}; |
17 | 17 |
} |
18 | 18 |
|
19 |
+ componentWillReceiveProps({ data }) { |
|
20 |
+ if (data !== this.props.data) { |
|
21 |
+ this.setState({ |
|
22 |
+ startTime: 0, |
|
23 |
+ endTime: maxTime(data) |
|
24 |
+ }) |
|
25 |
+ } |
|
26 |
+ } |
|
27 |
+ |
|
19 | 28 |
render() { |
20 | 29 |
const { data, measureRef, contentRect: { bounds: dimensions } } = this.props; |
21 | 30 |
const { startTime } = this.state; |
... | ... |
@@ -52,7 +61,7 @@ class Gannt extends React.PureComponent { |
52 | 52 |
const ticksCountX = scopeMinTime + scopeMaxTime; |
53 | 53 |
|
54 | 54 |
const width = Math.max(theme.gantt.maxWidth, dimensions.width); |
55 |
- const height = 100 + 1.75 * theme.gantt.job.height * processors.length; |
|
55 |
+ const height = Math.max(250 + 1.75 * theme.gantt.job.height * processors.length); |
|
56 | 56 |
|
57 | 57 |
const horizontalGuideLines = map( |
58 | 58 |
i => theme.gantt.margin.top + i * 1.75 * theme.gantt.job.height - i * 10, |
... | ... |
@@ -96,7 +105,7 @@ class Gannt extends React.PureComponent { |
96 | 96 |
height={theme.gantt.brush.height} |
97 | 97 |
stroke={theme.gantt.brush.stroke} |
98 | 98 |
onChange={({ startIndex, endIndex }) => |
99 |
- this.setState({ startTime: startIndex + 1, endTime: endIndex + 1 }) |
|
99 |
+ this.setState({ startTime: startIndex, endTime: endIndex + 1 }) |
|
100 | 100 |
} |
101 | 101 |
/> |
102 | 102 |
{scopeData.map((processorData, i) => ( |
... | ... |
@@ -1,6 +1,7 @@ |
1 | 1 |
import React from 'react'; |
2 | 2 |
import { Rectangle } from 'recharts'; |
3 | 3 |
import theme from '../theme'; |
4 |
+import { last } from 'rambda'; |
|
4 | 5 |
|
5 | 6 |
export default class Job extends React.PureComponent { |
6 | 7 |
render() { |
... | ... |
@@ -12,7 +13,8 @@ export default class Job extends React.PureComponent { |
12 | 12 |
formerStartTime, |
13 | 13 |
formerEndTime, |
14 | 14 |
startTime, |
15 |
- endTime |
|
15 |
+ endTime, |
|
16 |
+ delayed |
|
16 | 17 |
}, |
17 | 18 |
xAxis: { |
18 | 19 |
niceTicks, |
... | ... |
@@ -31,9 +33,12 @@ export default class Job extends React.PureComponent { |
31 | 31 |
- (typeof formerStartTime === 'undefined' ? startTime : formerStartTime) |
32 | 32 |
); |
33 | 33 |
|
34 |
- const width = (axisWidth / (niceTicks.length - 1)) * duration; |
|
34 |
+ // const width = (axisWidth / (niceTicks.length - 1)) * duration; |
|
35 |
+ const width = (axisWidth / ((last(niceTicks) - niceTicks[0]) || 1)) * duration; |
|
35 | 36 |
const height = theme.gantt.job.height; |
36 | 37 |
|
38 |
+ // console.log(this.props.payload, axisWidth, niceTicks, duration); |
|
39 |
+ |
|
37 | 40 |
return ( |
38 | 41 |
<JobBox |
39 | 42 |
x={x + 5} |
... | ... |
@@ -42,6 +47,7 @@ export default class Job extends React.PureComponent { |
42 | 42 |
height={height} |
43 | 43 |
duration={formerDuration} |
44 | 44 |
name={name} |
45 |
+ isDelayed={delayed} |
|
45 | 46 |
/> |
46 | 47 |
); |
47 | 48 |
} |
... | ... |
@@ -50,9 +56,11 @@ export default class Job extends React.PureComponent { |
50 | 50 |
class JobBox extends React.PureComponent { |
51 | 51 |
render() { |
52 | 52 |
const { x, y, width, height } = this.props; |
53 |
- let { duration, name } = this.props; |
|
53 |
+ let { duration, name, isDelayed } = this.props; |
|
54 |
+ |
|
55 |
+ const { stroke, textColor } = theme.gantt.job; |
|
54 | 56 |
|
55 |
- const { fill, stroke, textColor } = theme.gantt.job; |
|
57 |
+ const fill = isDelayed ? theme.gantt.job.fillError : theme.gantt.job.fill; |
|
56 | 58 |
|
57 | 59 |
return ( |
58 | 60 |
<React.Fragment> |
... | ... |
@@ -27,8 +27,15 @@ export const maxTime = data => { |
27 | 27 |
return reduce(max, -Infinity, processorsMaxTime); |
28 | 28 |
}; |
29 | 29 |
|
30 |
-export const normalizeData = data => |
|
31 |
- map(processorData => { |
|
30 |
+export const normalizeData = data => { |
|
31 |
+ forEach(processorData => { |
|
32 |
+ processorData.push({ |
|
33 |
+ startTime: last(processorData).endTime, |
|
34 |
+ processor: last(processorData).processor |
|
35 |
+ }); |
|
36 |
+ }, data); |
|
37 |
+ |
|
38 |
+ return map(processorData => { |
|
32 | 39 |
// if startTime would be days (thousands of seconds), set step to day |
33 | 40 |
const step = 1; // >= 1 |
34 | 41 |
|
... | ... |
@@ -54,11 +61,6 @@ export const normalizeData = data => |
54 | 54 |
|
55 | 55 |
const filledData = Object.values(dataObj); |
56 | 56 |
|
57 |
- filledData.push({ |
|
58 |
- startTime: last(processorData).endTime, |
|
59 |
- endTime: last(processorData).endTime + step, |
|
60 |
- processor: last(processorData).processor |
|
61 |
- }); |
|
62 |
- |
|
63 | 57 |
return filledData; |
64 |
- }, data); |
|
65 | 58 |
\ No newline at end of file |
59 |
+ }, data); |
|
60 |
+}; |
|
66 | 61 |
\ No newline at end of file |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
import { find, indexOf, last, map, prop, reduce, sort } from 'rambda'; |
2 | 2 |
import { max } from 'ramda'; |
3 | 3 |
|
4 |
-export const selectAlgorithms = (rows, preempt) => { |
|
4 |
+export const selectAlgorithms = (rows, preempt, flowShop) => { |
|
5 | 5 |
const processorsCount = rows.length; |
6 | 6 |
|
7 | 7 |
if (!processorsCount) return null; |
... | ... |
@@ -21,25 +21,45 @@ export const selectAlgorithms = (rows, preempt) => { |
21 | 21 |
return ['moore']; |
22 | 22 |
} |
23 | 23 |
|
24 |
- const existAnc = find( |
|
25 |
- ({ jobs }) => !!find(({ anc }) => Array.isArray(anc) && anc.length, jobs), |
|
26 |
- rows); |
|
24 |
+ if (flowShop) { |
|
25 |
+ let multi = ['campbel', 'grupt', 'palmer']; |
|
26 |
+ if (rows.length === 2) { |
|
27 |
+ multi.push('johnson'); |
|
28 |
+ } |
|
27 | 29 |
|
28 |
- if (existAnc) { |
|
29 |
- return ['vahy']; |
|
30 |
+ return multi; |
|
30 | 31 |
} |
31 | 32 |
|
32 |
- let multi = ['campbel', 'grupt', 'palmer']; |
|
33 | 33 |
|
34 |
- if (processorsCount === 2) { |
|
35 |
- multi.push('johnson'); |
|
36 |
- } |
|
34 |
+ let multi = ['vahy']; |
|
37 | 35 |
|
38 | 36 |
if (preempt) { |
39 | 37 |
multi.push('mcnaught'); |
40 | 38 |
} |
41 | 39 |
|
42 | 40 |
return multi; |
41 |
+ |
|
42 |
+ // const existAnc = find( |
|
43 |
+ // ({ jobs }) => !!find(({ anc }) => Array.isArray(anc) && anc.length, jobs), |
|
44 |
+ // rows); |
|
45 |
+ // |
|
46 |
+ // if (existAnc) { |
|
47 |
+ // return ['vahy']; |
|
48 |
+ // } |
|
49 |
+ // |
|
50 |
+ // return ['mcnaught']; |
|
51 |
+ // |
|
52 |
+ // let multi = ['campbel', 'grupt', 'palmer']; |
|
53 |
+ // |
|
54 |
+ // if (processorsCount === 2) { |
|
55 |
+ // multi.push('johnson'); |
|
56 |
+ // } |
|
57 |
+ // |
|
58 |
+ // if (preempt) { |
|
59 |
+ // multi.push('mcnaught'); |
|
60 |
+ // } |
|
61 |
+ // |
|
62 |
+ // return multi; |
|
43 | 63 |
}; |
44 | 64 |
|
45 | 65 |
export const najneomeskanejsiResult = (algoResults: []) => { |