Changeset 392

Show
Ignore:
Timestamp:
Tue May 13 09:32:27 2008
Author:
Alexander
Message:

Alex: scheduling script no longer creates redundant dependencies

Files:

Legend:

Unmodified
Added
Removed
Modified
  • scripts/trunk/Alter Schedule/One Task per Resource by Schedule Priority.py

    r391 r392  
    19 19  
    20 20 # 080510 - first version based on One Task per Resource in Project  
      21 # 080513 - Alex - remove redundant dependencies, slight refactoring  
    21 22  
    22 23 debug = 0  
     
    28 29         self.SetStatusText(s)  
    29 30  
      31 def RemovePrerequisitesForTask(taskid, reason):  
      32     prereqs = Data.SearchByColumn(Data.Dependency,  
      33                                   {'TaskID': taskid, 'Reason': reason})  
      34     for k in prereqs:  
      35         change = {'Table': 'Dependency',  
      36                   'ID': k,  
      37                   'Reason': None,  
      38                   'zzStatus': 'deleted',  
      39                  }  
      40         Data.Update(change)  
      41  
    30 42 def RemoveDependencies(projectid, reason):  
    31 43     if debug: print "projectid %s, reason %s" % (projectid, reason)  
     
    105 117     return result  
    106 118  
      119 def UpdateOtherList(oldlist):  
      120     dt = Data.Database['Task']  
      121     result = []  
      122     for oldes, oldef, tid in oldlist:  
      123         es = dt[tid].get('hES')  
      124         ef = dt[tid].get('hEF')  
      125         result.append((es, ef, tid))  
      126     return result  
      127  
    107 128 def UpdateWorkList(oldlist):  
    108 129     dt = Data.Database['Task']  
     
    152 173 # algorithm:  
    153 174 # sort tasks by start hour, report row #, task id  
    154   # for each task:  
    155   #     if any of the following tasks start before this one ends  
    156   #     and has one of the same people working on it  
    157   #         add a dependency between this task and the other task  
      175 # take the earliest task  
      176 # for each task in our list of prior commitments (otherlist)  
      177 #     if that task starts before this one ends  
      178 #     and ends after this one starts  
      179 #     and has any of the same people working on it  
      180 #         remove any previous OTRP dependencies  
      181 #         add a dependency between that task and this one  
    158 182 #         recalculate the critical path  
    159   #         return true  
    160   # return false  
      183 #         start over with the new earliest task  
      184 # if no overlaps were found  
      185 #     remove this task from the list  
      186 #     and add it to our list of commitments  
    161 187  
    162 188     # create short cuts to all of the tables used  
     
    208 234                 if Overlap(resourcesA, resourcesB):  
    209 235                     okay = False  # overlapping tasks use same resource  
      236                     RemovePrerequisitesForTask(taskid, 'otrp')  
    210 237                     AddDependency(other_id, taskid, 'otrp')  
    211 238                     break  
    212 239             i += 1  
    213           if not okay:  
      240         if okay:  
      241             # this task is compatible with all our prior commitments  
      242             # add it to our list of commitments  
      243             del worklist[0]  
      244             otherlist.append((es, ef, taskid))  
      245             otherlist.sort()  
      246         else:  
    214 247             Data.GanttCalculation()  
    215 248             worklist = UpdateWorkList(worklist)  # with new start times  
    216 249             worklist.sort()  
    217               continue  
      250             otherlist = UpdateOtherList(otherlist)  # with new start times  
      251             otherlist.sort()  
      252 #            continue  
    218 253  
    219 254         # if a second task in this project would like to use one of  
     
    221 256         #   have that second task wait until this task is finished  
    222 257  
    223           okay = True  
    224           i = 1  
    225           while i < len(worklist) and dt[worklist[i][2]].get('hES') < ef:  # overlapping tasks  
    226               resourcesB = GetResourceIDs(worklist[i][2])  
    227               if Overlap(resourcesA, resourcesB):  
    228                   okay = False  # overlapping tasks use same resource  
    229                   AddDependency(taskid, worklist[i][2], 'otrp')  
    230                   break  
    231               i += 1  
    232           if okay:  
    233               del worklist[0]  
    234           else:  
    235               Data.GanttCalculation()  
    236               worklist = UpdateWorkList(worklist)  # with new start times  
    237               worklist.sort()  
      258 #        okay = True  
      259 #        i = 1  
      260 #        while i < len(worklist) and dt[worklist[i][2]].get('hES') < ef:  # overlapping tasks  
      261 #            resourcesB = GetResourceIDs(worklist[i][2])  
      262 #            if Overlap(resourcesA, resourcesB):  
      263 #                okay = False  # overlapping tasks use same resource  
      264 #                AddDependency(taskid, worklist[i][2], 'otrp')  
      265 #                break  
      266 #            i += 1  
      267 #        if okay:  
      268 #            del worklist[0]  
      269 #        else:  
      270 #            Data.GanttCalculation()  
      271 #            worklist = UpdateWorkList(worklist)  # with new start times  
      272 #            worklist.sort()  
      273  
    238 274         count += 1  
    239 275         if count > 2000: