예제 #1
0
파일: jobset.py 프로젝트: oar-team/evalys
 def get_free_slots_by_resources(x):
     for res in range(resource_intervals[0], resource_intervals[1] + 1):
         if intersection(x.allocated_processors, [(res, res)]):
             free_resources_gaps[res].append(x.execution_time)
예제 #2
0
파일: jobset.py 프로젝트: oar-team/evalys
    def free_slots(self, begin_time=0, end_time=None):
        '''
        :returns: a DataFrame (compatible with a JobSet) that contains all
            the not overlapping square free slots of this JobSet maximzing the
            time. It can be transform to a JobSet to be plot as gantt chart.
        '''
        # slots_time contains tuple of
        # (slot_begin_time,free_resources_intervals)
        free_interval_serie = self.free_intervals(begin_time, end_time)
        slots_time = [(free_interval_serie.time[0],
                      [self.res_bounds])]
        new_slots_time = slots_time
        columns = ['jobID', 'allocated_processors',
                   'starting_time', 'finish_time', 'execution_time',
                   'submission_time']
        free_slots_df = pd.DataFrame(columns=columns)
        prev_free_itvs = [self.res_bounds]
        slots = 0
        for i, curr_row in free_interval_serie.iterrows():
            if i == 0:
                continue
            new_slots_time = []
            curr_time = curr_row.time
            taken_resources = difference(prev_free_itvs,
                                         curr_row.free_itvs)
            freed_resources = difference(curr_row.free_itvs,
                                         prev_free_itvs)
            if i == len(free_interval_serie) - 1:
                taken_resources = [self.res_bounds]
            if taken_resources:
                # slot ends: store it and update free slot
                for begin_time, itvs in slots_time:
                    to_update = intersection(itvs, taken_resources)
                    if to_update != []:
                        # store new slots
                        slots = slots + 1
                        new_slot = [str(slots),
                                    to_update,
                                    begin_time,
                                    curr_time,
                                    curr_time - begin_time,
                                    begin_time]
                        free_slots_df.loc[slots] = new_slot
                        # remove free slots
                        free_res = difference(itvs, to_update)
                        if free_res != []:
                            new_slots_time.append((begin_time, free_res))
                    else:
                        new_slots_time.append((begin_time, itvs))

            if freed_resources:
                # slots begin: udpate free slot
                if not new_slots_time:
                    new_slots_time = slots_time
                new_slots_time.append((curr_time, freed_resources))

            # update previous
            prev_free_itvs = curr_row.free_itvs
            # clean slots_free
            slots_time = new_slots_time
        return free_slots_df