MCPcopy Index your code
hub / github.com/geekcomputers/Python / schedule

Method schedule

Job_scheduling.py:19–40  ·  view source on GitHub ↗

Parameteres : total_jobs and list of deadline of jobs Returns : List of jobs_id which are profitable and can be done before deadline >>> a = Scheduling([(0, 13, 10),(1, 2, 20),(2, 33, 30),(3, 16, 40)]) >>> a.schedule( 3, [3, 4, 5]) [(1, 2

(self, total_jobs: int, deadline: List[int])

Source from the content-addressed store, hash-verified

17 self.jobs = jobs
18
19 def schedule(self, total_jobs: int, deadline: List[int]) -> List[int]:
20 """
21 Parameteres : total_jobs and list of deadline of jobs
22 Returns : List of jobs_id which are profitable and can be done before
23 deadline
24 >>> a = Scheduling([(0, 13, 10),(1, 2, 20),(2, 33, 30),(3, 16, 40)])
25 >>> a.schedule( 3, [3, 4, 5])
26 [(1, 2, 20), (2, 33, 30)]
27 >>> a = Scheduling([(0, 13, 10),(1, 2, 20),(2, 33, 30),(3, 16, 40)])
28 >>> a.schedule( 4, [13, 2, 33, 16])
29 [(1, 2, 20), (2, 33, 30), (3, 16, 40)]
30 """
31 self.j = [self.jobs[1]]
32 self.x = 2
33 while self.x < total_jobs:
34 self.k = self.j.copy()
35 self.k.append(self.jobs[self.x])
36 self.x += 1
37 if self.feasible(self.k, deadline):
38 self.j = self.k.copy()
39
40 return self.j
41
42 def feasible(self, profit_jobs: List[int], deadline: List[int]) -> bool:
43 """

Callers 2

mainFunction · 0.95
watcherFunction · 0.80

Calls 3

feasibleMethod · 0.95
copyMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected