-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
93 lines (73 loc) · 2.58 KB
/
run.py
File metadata and controls
93 lines (73 loc) · 2.58 KB
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
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
def check_pe_area(pe_area):
x,y = pe_area.shape
for i in range(x):
for j in range(y):
if pe_area[i][j] > 1:
return False
return True
# make 16 by 19 array of zeros
pe_area = np.zeros((16, 19))
block_a = np.ones((3, 3))
block_b = np.ones((2, 2))
block_c = np.ones((1, 5))
block_d = np.ones((2, 5))
block_e = np.ones((3, 4))
block_f = np.ones((6, 1))
import_block_list = [
[block_a, block_d, block_e],
[block_b, block_b, block_c],
[block_e, block_c, block_c],
[block_e, block_e, block_b],
[block_b, block_b, block_e],
[block_a, block_a, block_b],
[block_b, block_a, block_b],
[block_b, block_c, block_d],
[block_b, block_c, block_a],
[block_e, block_d, block_e]
]
export_block_schedule_list = [
[3, 6, 5], [8, 10, 7], [11, 12, 9],
[12, 12, 13], [15, 17, 15],
[16, 18, 17], [19, 20, 19], [20, 21, 22],
[22, 21, 23], [23, 23, 24]
]
days = 30
export_block_list = [ [] for _ in range(days)]
pe_height, pe_width = pe_area.shape
temp_pe_area = None
flag = False
for day in range(days):
try:
block_list = import_block_list[day]
block_duration_days = export_block_schedule_list[day]
except IndexError:
block_list = []
block_duration_days = []
if len(export_block_list[day]) > 0:
for block, (y, x) in export_block_list[day]:
pe_area[y:y+block.shape[0], x:x+block.shape[1]] = \
pe_area[y:y+block.shape[0], x:x+block.shape[1]] - block
sns.heatmap(pe_area, annot=True, linewidths=.5, cmap="YlGnBu")
plt.show()
for block, duraction_day in zip(block_list, block_duration_days):
block_size_y, block_size_x = block.shape
for y in range(pe_height-block_size_y+1):
for x in range(pe_width-block_size_x+1):
temp_pe_area = pe_area.copy()
temp_pe_area[y:y+block_size_y, x:x+block_size_x] = \
temp_pe_area[y:y+block_size_y, x:x+block_size_x] + block
if check_pe_area(temp_pe_area):
pe_area = temp_pe_area.copy()
export_block_list[duraction_day].append((block, (y, x)))
flag = True
break
else:
continue
if flag:
flag = False
break
sns.heatmap(pe_area, annot=True, linewidths=.5, cmap="YlGnBu")
plt.show()