Advertisement
Guest User

Untitled

a guest
Apr 24th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. class criticalPath:
  2.    
  3.     def __init__(self):
  4.         '''
  5.        Initialize all the variables we're going to use to calculate the critical path
  6.        '''
  7.         self.id = None
  8.         self.pred = tuple()
  9.         self.dur = None
  10.         self.est = None
  11.         self.lst = None
  12.         #list to store all the objects
  13.         self.all_objects = list()
  14.        
  15.     def set_properties(self, name, predecessor, duration):
  16.         self.id = name
  17.         self.pred = tuple(predecessor)
  18.         self.dur = duration
  19.        
  20.  
  21. def main():
  22.     #starting_nodes = list()
  23.     object_list = list()
  24.    
  25.     A = criticalPath()
  26.     A.set_properties('A', '0', 3)
  27.    
  28.     B = criticalPath()
  29.     B.set_properties('B', '0', 6)
  30.    
  31.     C = criticalPath()
  32.     C.set_properties('C', 'A', 12)
  33.    
  34.     D = criticalPath()
  35.     D.set_properties('D', 'B', 4)
  36.    
  37.    
  38.    
  39.     tmp_list = list()
  40.     tmp_list.append(A)
  41.     tmp_list.append(B)
  42.     object_list.append(tmp_list)
  43.    
  44.     tmp_list = list()
  45.     tmp_list.append(C)
  46.     tmp_list.append(D)
  47.     object_list.append(tmp_list)
  48.    
  49.     '''for i in object_list:
  50.        if '0' in i.pred:
  51.            _list = list()
  52.            _list.append(i)
  53.            starting_nodes.append(_list)
  54.            
  55.    
  56.    print(starting_nodes)'''
  57.     print(max(object_list, key=sum(object_list.dur)))
  58.    
  59. if __name__ == '__main__': main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement