-
Notifications
You must be signed in to change notification settings - Fork 0
/
sequencing.py
45 lines (34 loc) · 1.28 KB
/
sequencing.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
# -*- coding: utf-8 -*-
"""sequencing.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1lgtV99u5NuZ8OcVRp_gkwkhzhKFkLbHW
"""
class Job:
def __init__(self, id, time_machine_A, time_machine_B):
self.id = id
self.time_machine_A = time_machine_A
self.time_machine_B = time_machine_B
def schedule_jobs(jobs):
jobs.sort(key=lambda job: min(job.time_machine_A, job.time_machine_B) / 2)
machineA = []
machineB = []
for job in jobs:
min_time = min(job.time_machine_A, job.time_machine_B) / 2
if job.time_machine_A <= job.time_machine_B:
machineA.append(job.id)
else:
machineB.append(job.id)
print("Machine A job sequence:", machineA)
print("Machine B job sequence:", machineB[::-1]) # Reverse the order for Machine B
def main():
m = int(input("Enter the number of jobs: "))
jobs = []
for i in range(m):
id = i + 1
time_machine_A = int(input(f"Enter processing time for job {id} on Machine A: "))
time_machine_B = int(input(f"Enter processing time for job {id} on Machine B: "))
jobs.append(Job(id, time_machine_A, time_machine_B))
schedule_jobs(jobs)
if __name__ == "__main__":
main()