-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw.py
82 lines (55 loc) · 1.6 KB
/
draw.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from tabulate import tabulate
from instances import get_instance
from Model import Job, Machine, Result
from copy import copy
def draw(machines, info: bool = False):
str = ""
for m in machines:
str += __get_machine(m) + '\n'
print(str)
def draw_table(jobs):
job_ids = ['j{}'.format(i.id) for i in jobs]
process_times = [ i.process_time for i in jobs]
weights = [ i.weight for i in jobs]
table = [ job_ids, process_times]
if weights[0] != 1:
table.append(weights)
print(tabulate(table, headers='firstrow', tablefmt='fancy_grid'))
def draw_series_job(jobs):
arrow = " => "
str = "=============== Jobs series ================\n"
ids = [ job.id for job in jobs]
while (ids):
str += arrow + "| {} |".format(ids[0])
del ids[0]
str += "\n"
print(str)
def draw_Cmax(id, Cmax):
str = "The Cmax is M{}: {} \n".format(id, Cmax)
print(str)
def __get_machine(machine: Machine):
jobs = machine.jobs
str = "M{} : ".format(machine.id)
for idx, j in enumerate(jobs):
str += __get_jobs(j, idx)
return str
def __get_jobs(job: Job, format):
sym0 = "▒"
sym1 = "▓"
time = ""
if format%2 == 0:
sym = sym0
else:
sym = sym1
j = copy(job)
for i in range(job.idle):
time += " "
process_time = j.process_time
# if process_time > 10:
# process_time = process_time - 1
for i in range(process_time):
if i == int(process_time/2):
time += str(job.id)
else:
time += sym
return time