Last active
August 29, 2015 14:04
-
-
Save tokoroten/46ee0fbd9a09d69d081c to your computer and use it in GitHub Desktop.
http://brevis.exblog.jp/22236990/ 稼働率100%の施設における在庫量とリードタイムのシミュレーション
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
days, input_load, worker_stacks, total_stacks, output, ave_lead_time | |
case 100% input 1...6 | |
0 2 [2, 0, 0, 0, 0] 2 0 5 | |
1 5 [5, 2, 0, 0, 0] 7 0 6 | |
2 2 [2, 5, 2, 0, 0] 9 0 6 | |
3 3 [3, 5, 2, 2, 0] 12 0 6 | |
4 3 [3, 4, 4, 2, 2] 15 0 7 | |
5 6 [6, 3, 4, 5, 1] 19 2 8 | |
6 1 [4, 3, 6, 1, 5] 19 1 8 | |
7 4 [4, 4, 3, 6, 2] 19 4 8 | |
8 3 [5, 5, 1, 8, 1] 20 2 9 | |
9 5 [5, 5, 5, 7, 2] 24 1 9 | |
10 6 [6, 5, 8, 6, 4] 29 1 11 | |
11 2 [6, 4, 8, 8, 1] 27 4 11 | |
12 2 [6, 2, 6, 12, 2] 28 1 10 | |
13 5 [6, 5, 3, 13, 4] 31 2 11 | |
14 6 [8, 4, 5, 14, 2] 33 4 12 | |
15 1 [4, 8, 1, 18, 2] 33 1 13 | |
16 4 [4, 11, 1, 15, 4] 35 2 14 | |
17 2 [3, 8, 6, 12, 4] 33 4 12 | |
18 1 [3, 7, 7, 11, 2] 30 4 10 | |
19 5 [5, 4, 11, 7, 6] 33 2 12 | |
20 3 [3, 5, 13, 6, 8] 35 1 12 | |
21 6 [6, 6, 11, 5, 12] 40 1 14 | |
22 5 [9, 4, 11, 8, 10] 42 3 15 | |
23 2 [8, 6, 8, 9, 9] 40 4 14 | |
24 2 [6, 6, 9, 10, 5] 36 6 12 | |
25 6 [10, 5, 9, 7, 8] 39 3 13 | |
26 5 [10, 7, 11, 5, 9] 42 2 14 | |
27 4 [12, 3, 13, 4, 9] 41 5 14 | |
28 4 [11, 5, 13, 6, 7] 42 3 14 | |
29 2 [10, 7, 13, 4, 6] 40 4 13 | |
30 6 [10, 11, 9, 7, 8] 45 1 15 | |
31 2 [9, 11, 9, 9, 3] 41 6 14 | |
32 6 [12, 11, 11, 7, 3] 44 3 15 | |
33 4 [10, 16, 8, 5, 6] 45 3 15 | |
34 6 [10, 16, 13, 3, 7] 49 2 15 | |
35 5 [12, 13, 15, 4, 4] 48 6 17 | |
36 4 [10, 13, 15, 7, 3] 48 4 15 | |
37 6 [11, 14, 17, 4, 5] 51 3 17 | |
38 1 [7, 13, 22, 1, 7] 50 2 16 | |
39 5 [9, 13, 23, 2, 3] 50 5 16 | |
40 5 [9, 15, 23, 3, 2] 52 3 17 | |
41 6 [9, 17, 22, 5, 3] 56 2 18 | |
42 3 [11, 16, 22, 5, 4] 58 1 20 | |
43 4 [11, 15, 25, 3, 7] 61 1 20 | |
44 5 [13, 14, 27, 2, 9] 65 1 20 | |
45 4 [11, 19, 24, 4, 5] 63 6 21 | |
46 1 [9, 20, 22, 4, 4] 59 5 20 | |
47 3 [7, 20, 23, 7, 1] 58 4 18 | |
48 6 [12, 16, 24, 5, 6] 63 1 20 | |
49 3 [11, 17, 22, 6, 6] 62 4 20 | |
50 6 [12, 17, 23, 6, 7] 65 3 20 | |
51 1 [9, 17, 24, 3, 7] 60 6 18 | |
52 2 [6, 16, 29, 1, 6] 58 4 19 | |
53 6 [10, 14, 28, 5, 6] 63 1 19 | |
54 2 [8, 14, 30, 2, 7] 61 4 19 | |
55 3 [9, 13, 29, 4, 4] 59 5 20 | |
56 2 [5, 17, 25, 6, 4] 57 4 19 | |
57 1 [1, 16, 26, 9, 2] 54 4 18 | |
58 1 [1, 16, 26, 7, 3] 53 2 17 | |
59 2 [2, 11, 27, 11, 1] 52 3 18 | |
60 3 [3, 12, 24, 11, 4] 54 1 18 | |
61 1 [1, 9, 27, 12, 5] 54 1 18 | |
62 4 [4, 7, 28, 11, 3] 53 5 17 | |
63 1 [3, 6, 29, 11, 4] 53 1 18 | |
64 4 [5, 6, 27, 14, 1] 53 4 17 | |
65 5 [9, 3, 27, 14, 4] 57 1 18 | |
66 2 [6, 6, 26, 16, 1] 55 4 18 | |
67 4 [5, 8, 26, 13, 6] 58 1 19 | |
68 6 [10, 4, 28, 13, 3] 58 6 18 | |
69 6 [11, 7, 27, 14, 2] 61 3 19 | |
70 5 [12, 10, 26, 12, 4] 64 2 21 | |
71 1 [11, 9, 28, 12, 3] 63 2 20 | |
72 5 [11, 8, 30, 15, 1] 65 3 22 | |
73 4 [11, 11, 30, 12, 4] 68 1 23 | |
74 4 [12, 13, 25, 12, 6] 68 4 22 | |
75 4 [14, 12, 27, 8, 10] 71 1 22 | |
76 3 [15, 8, 27, 10, 11] 71 3 23 | |
77 3 [15, 8, 24, 10, 13] 70 4 22 | |
78 4 [15, 8, 24, 8, 13] 68 6 22 | |
79 5 [14, 10, 27, 3, 16] 70 3 21 | |
80 4 [13, 13, 28, 3, 16] 73 1 22 | |
81 4 [16, 9, 27, 8, 15] 75 2 24 | |
82 1 [11, 10, 26, 9, 18] 74 2 24 | |
83 3 [10, 12, 25, 6, 18] 71 6 23 | |
84 4 [9, 11, 27, 8, 16] 71 4 23 | |
85 3 [9, 8, 30, 9, 17] 73 1 23 | |
86 6 [14, 7, 28, 7, 17] 73 6 21 | |
87 6 [18, 4, 27, 10, 15] 74 5 24 | |
88 3 [15, 7, 28, 11, 10] 71 6 22 | |
89 4 [15, 10, 27, 9, 13] 74 1 23 | |
90 3 [16, 11, 27, 6, 16] 76 1 24 | |
91 3 [13, 12, 27, 9, 15] 76 3 24 | |
92 6 [17, 11, 26, 10, 14] 78 4 24 | |
93 6 [17, 11, 29, 10, 13] 80 4 25 | |
94 4 [16, 15, 24, 12, 16] 83 1 26 | |
95 5 [20, 15, 22, 9, 21] 87 1 27 | |
96 4 [19, 16, 21, 8, 24] 88 3 27 | |
97 5 [22, 16, 21, 4, 29] 92 1 29 | |
98 3 [23, 13, 21, 5, 31] 93 2 28 | |
99 3 [21, 13, 22, 6, 32] 94 2 29 | |
case 85% input 1...5 | |
0 5 [5, 0, 0, 0, 0] 5 0 6 | |
1 3 [7, 1, 0, 0, 0] 8 0 6 | |
2 3 [5, 5, 1, 0, 0] 11 0 7 | |
3 3 [7, 1, 5, 1, 0] 14 0 7 | |
4 4 [9, 2, 2, 4, 1] 18 0 8 | |
5 3 [7, 5, 2, 3, 3] 20 1 7 | |
6 3 [6, 4, 6, 1, 3] 20 3 8 | |
7 3 [8, 1, 4, 6, 2] 21 2 9 | |
8 1 [6, 3, 1, 6, 4] 20 2 8 | |
9 4 [6, 4, 3, 3, 4] 20 4 8 | |
10 3 [7, 2, 6, 1, 5] 21 2 8 | |
11 4 [10, 1, 6, 2, 3] 22 3 8 | |
12 3 [9, 4, 4, 4, 2] 23 2 10 | |
13 1 [7, 3, 4, 4, 4] 22 2 9 | |
14 1 [7, 3, 2, 3, 4] 19 4 7 | |
15 4 [9, 2, 3, 2, 4] 20 3 8 | |
16 4 [7, 6, 2, 4, 1] 20 4 8 | |
17 5 [7, 5, 6, 2, 4] 24 1 9 | |
18 4 [7, 4, 7, 4, 4] 26 2 10 | |
19 1 [5, 4, 7, 5, 3] 24 3 9 | |
20 5 [8, 3, 6, 5, 4] 26 3 10 | |
21 2 [4, 6, 6, 3, 5] 24 4 9 | |
22 2 [2, 4, 9, 5, 1] 21 5 9 | |
23 4 [4, 4, 5, 8, 3] 24 1 10 | |
24 2 [2, 4, 8, 3, 6] 23 3 9 | |
25 5 [6, 4, 6, 3, 6] 25 3 9 | |
26 5 [10, 1, 8, 2, 7] 28 2 10 | |
27 1 [5, 6, 4, 5, 4] 24 5 10 | |
28 2 [5, 6, 2, 4, 8] 25 1 10 | |
29 4 [6, 4, 5, 2, 9] 26 3 10 | |
30 4 [9, 2, 5, 4, 8] 28 2 11 | |
31 3 [7, 6, 1, 5, 10] 29 2 10 | |
32 5 [11, 6, 1, 5, 5] 28 6 11 | |
33 1 [6, 7, 5, 1, 5] 24 5 9 | |
34 3 [3, 9, 4, 5, 2] 23 4 9 | |
35 5 [5, 8, 7, 2, 4] 26 2 10 | |
36 3 [6, 6, 5, 6, 2] 25 4 9 | |
37 4 [9, 5, 2, 5, 6] 27 2 10 | |
38 3 [7, 7, 3, 4, 6] 27 3 9 | |
39 4 [8, 7, 3, 4, 6] 28 3 10 | |
40 1 [3, 12, 1, 3, 7] 26 3 9 | |
41 3 [5, 7, 6, 3, 3] 24 5 8 | |
42 1 [5, 6, 5, 3, 4] 23 2 9 | |
43 4 [4, 8, 7, 1, 3] 23 4 9 | |
44 1 [3, 4, 12, 1, 3] 23 1 9 | |
45 2 [2, 6, 9, 4, 1] 22 3 9 | |
46 1 [1, 3, 13, 1, 4] 22 1 9 | |
47 5 [5, 2, 14, 1, 1] 23 4 9 | |
48 5 [6, 4, 13, 3, 1] 27 1 10 | |
49 4 [5, 7, 12, 3, 3] 30 1 10 | |
50 3 [5, 8, 12, 2, 4] 31 2 12 | |
51 5 [7, 9, 13, 1, 2] 32 4 11 | |
52 2 [8, 9, 12, 2, 1] 32 2 12 | |
53 5 [7, 9, 13, 5, 2] 36 1 12 | |
54 5 [11, 6, 13, 6, 3] 39 2 13 | |
55 3 [10, 8, 14, 6, 1] 39 3 13 | |
56 1 [9, 7, 13, 4, 6] 39 1 13 | |
57 1 [6, 7, 14, 3, 4] 34 6 11 | |
58 1 [5, 5, 13, 6, 2] 31 4 11 | |
59 3 [3, 7, 12, 7, 3] 32 2 10 | |
60 1 [2, 8, 11, 5, 5] 31 2 12 | |
61 4 [5, 3, 12, 6, 6] 32 3 11 | |
62 4 [8, 2, 10, 6, 4] 30 6 11 | |
63 4 [6, 6, 6, 9, 6] 33 1 11 | |
64 1 [6, 2, 6, 13, 1] 28 6 10 | |
65 5 [9, 2, 7, 8, 6] 32 1 11 | |
66 3 [9, 3, 7, 8, 7] 34 1 11 | |
67 1 [4, 8, 6, 4, 11] 33 2 13 | |
68 4 [4, 6, 9, 4, 10] 33 4 12 | |
69 5 [5, 6, 11, 2, 8] 32 6 12 | |
70 1 [2, 5, 14, 3, 6] 30 3 10 | |
71 4 [5, 5, 10, 5, 6] 31 3 11 | |
72 1 [1, 7, 9, 5, 7] 29 3 10 | |
73 5 [5, 7, 7, 6, 8] 33 1 11 | |
74 3 [6, 8, 5, 4, 11] 34 2 13 | |
75 1 [4, 7, 5, 4, 12] 32 3 12 | |
76 4 [4, 10, 2, 4, 15] 35 1 13 | |
77 3 [3, 13, 2, 1, 18] 37 1 13 | |
78 4 [4, 11, 5, 2, 18] 40 1 15 | |
79 2 [2, 14, 3, 3, 14] 36 6 11 | |
80 1 [1, 10, 6, 5, 12] 34 3 12 | |
81 5 [5, 10, 4, 3, 16] 38 1 13 | |
82 5 [8, 7, 5, 6, 12] 38 5 13 | |
83 1 [4, 6, 6, 9, 13] 38 1 13 | |
84 3 [3, 6, 7, 9, 10] 35 6 11 | |
85 5 [5, 8, 6, 5, 10] 34 6 12 | |
86 2 [2, 10, 5, 4, 12] 33 3 12 | |
87 2 [2, 6, 8, 3, 14] 33 2 11 | |
88 3 [3, 5, 6, 5, 16] 35 1 12 | |
89 1 [2, 6, 6, 2, 17] 33 3 11 | |
90 5 [5, 7, 5, 2, 18] 37 1 13 | |
91 1 [1, 7, 8, 3, 13] 32 6 11 | |
92 2 [2, 7, 4, 5, 15] 33 1 12 | |
93 4 [4, 8, 1, 4, 14] 31 6 12 | |
94 2 [4, 8, 2, 1, 15] 30 3 12 | |
95 1 [1, 9, 3, 2, 10] 25 6 9 | |
96 2 [2, 7, 3, 3, 9] 24 3 8 | |
97 5 [5, 8, 2, 2, 8] 25 4 10 | |
98 3 [7, 7, 2, 2, 7] 25 3 8 | |
99 5 [6, 8, 5, 2, 4] 25 5 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: utf-8 | |
#http://brevis.exblog.jp/22236990/ | |
import random | |
import math | |
class workflow(): | |
def __init__(self, worker_num = 5, max_worker_process_speed = 6): | |
self.worker_num = worker_num | |
self.max_worker_process_speed = max_worker_process_speed | |
self.worker_stack = [0] * self.worker_num | |
def process(self): | |
worker_process_speed = [random.randint(1, self.max_worker_process_speed) for i in xrange(self.worker_num)] | |
if self.worker_stack[-1] < worker_process_speed[-1]: | |
output = self.worker_stack[-1] | |
self.worker_stack[-1] = 0 | |
else: | |
output = worker_process_speed[-1] | |
self.worker_stack[-1] -= worker_process_speed[-1] | |
for i in xrange(self.worker_num - 1, 0, -1): | |
next = i | |
prev = i -1 | |
if self.worker_stack[prev] < worker_process_speed[prev]: | |
self.worker_stack[next] += self.worker_stack[prev] | |
self.worker_stack[prev] = 0 | |
else: | |
self.worker_stack[next] += worker_process_speed[prev] | |
self.worker_stack[prev] -= worker_process_speed[prev] | |
return output | |
def input(self, workload): | |
output = self.process() | |
self.worker_stack[0] += workload | |
return output | |
def random_input(self): | |
return self.input(random.randint(1,6)) | |
def get_leadtime(self): | |
leadtime = 0 | |
ave_process_speed = (self.max_worker_process_speed + 1) / 2.0 | |
for i in xrange(self.worker_num): | |
if self.worker_stack[i] >= ave_process_speed: | |
leadtime += int(math.ceil(self.worker_stack[i] / ave_process_speed)) | |
else: | |
leadtime += 1 | |
return leadtime | |
def sim(max_input = 6): | |
wf = workflow(5, 6) | |
for i in xrange(100): | |
input = random.randint(1, max_input) | |
output = wf.input(input) | |
lead_time = wf.get_leadtime() | |
print i, input, wf.worker_stack, sum(wf.worker_stack), output, lead_time | |
def main(): | |
print "days, input_load, worker_stacks, total_stacks, output, ave_lead_time" | |
print "case 100% input 1...6" | |
sim(6) | |
print "case 85% input 1...5" | |
sim(5) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment