-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_set.py
63 lines (44 loc) · 1.29 KB
/
task_set.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
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
from task import Task
class TaskSet:
"""Task Set Class
Attributes:
tasks (list): List of Task objects
utility (float): Utility of the task set
self.feasible (bool): Whether the task set is feasible
"""
def __init__(self, tasks=[]):
self.tasks = tasks
def get_all(self):
"""Get all task set tasks
Returns:
list: list of tasks
"""
return self.tasks
def get_ready_tasks(self, time):
"""Get ready tasks of task set.
Returns:
a list of ready tasks.
"""
array = []
for task in self.tasks:
if task.is_ready(time):
array.append(task)
return array
def set_tasks(self, tasks):
"""Set new tasks.
Args:
tasks (list): list of new tasks.
"""
self.tasks = tasks
def add_task(self, task):
"""Add a task to the task set
Args:
task (Task): Task object to add
"""
self.tasks.append(task)
def status(self):
"""Return an status of task set.
Returns:
int: Number of tasks
"""
return len(self.tasks)