-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtask.py
27 lines (22 loc) · 905 Bytes
/
task.py
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
import numpy as np
class Task:
def __init__(self, resources, duration, label):
self.resources = resources
self.duration = duration
self.label = label
self.dimension = len(self.resources)
def summary(self, bg_shape = None):
if bg_shape == None:
bg_shape = (self.duration, max(self.resources))
if self.dimension > 0:
state_matrices = [np.full(bg_shape, 255) for i in range(self.dimension)]
for i in range(self.dimension):
for row in range(self.duration):
for col in range(self.resources[i]):
state_matrices[i][row, col] = 0
temp = state_matrices[0]
for i in range(1, self.dimension):
temp = np.concatenate((temp, state_matrices[i]), axis=1)
return temp
else:
return None