def _reschedule(self): new_tasks = [] for task_id in self.order_list: if self.mfss_allows_execution(task_id) and task_id in self.tasks_to_do.keys(): new_task = self.allocate_resources(self.tasks_to_do[task_id]) if new_task is not None: new_tasks.append(new_task) del self.tasks_to_do[task_id] else: break if len(new_tasks) == 0 and len(self.currently_assigned_resoruces) == 0 and len(self.tasks_to_do) is not 0: if self.ignore_infeasible_schedules == False: raise UnfeasibleScheduleException() else: Logger.warning("unfeasible schedule encountered. Ignoring mfss") for task_id in self.tasks_to_do.keys(): new_task = self.allocate_resources(self.tasks_to_do[task_id]) if new_task is not None: new_tasks.append(new_task) del self.tasks_to_do[task_id] break return new_tasks
def _reschedule(self): new_tasks = [] tasks_to_remove = [] self.eligble_to_run = self.get_tasks_eligible_to_run() for task_id in self.order_list: if self.bottleneck_allows_execution(task_id, self.eligble_to_run): new_task = self.allocate_resources(self.tasks_to_do[task_id]) self.eligble_to_run = self.get_tasks_eligible_to_run() if new_task == None: pass else: new_tasks.append(new_task) del self.tasks_to_do[task_id] tasks_to_remove.append(task_id) self.already_executed.append(task_id) [self.order_list.remove(task) for task in tasks_to_remove] if len(new_tasks) == 0 and len(self.currently_assigned_resoruces) == 0 and len(self.tasks_to_do) > 0: if not self.ignore_infeasible_schedules: raise UnfeasibleScheduleException() else: Logger.warning("Unfeasible schedule encountered. Ignoring mfss") for task_id in self.order_list: new_task = self.allocate_resources(self.tasks_to_do[task_id]) if new_task == None: pass else: new_tasks.append(new_task) del self.tasks_to_do[task_id] tasks_to_remove.append(task_id) self.already_executed.append(task_id) [self.order_list.remove(task) for task in tasks_to_remove] return new_tasks
def _reschedule(self): new_tasks = [] tasks_to_remove = [] for task_id in self.order_list: if self.mfss_allows_execution(task_id): new_task = self.allocate_resources(self.tasks_to_do[task_id]) if new_task == None: pass else: new_tasks.append(new_task) del self.tasks_to_do[task_id] tasks_to_remove.append(task_id) self.already_executed.append(task_id) [self.order_list.remove(task) for task in tasks_to_remove] if len(new_tasks) == 0 and len(self.currently_assigned_resoruces) == 0 and len(self.tasks_to_do) > 0: if not self.ignore_infeasible_schedules: raise UnfeasibleScheduleException() else: Logger.warning("Unfeasible schedule encountered. Ignoring mfss") for task_id in self.order_list: new_task = self.allocate_resources(self.tasks_to_do[task_id]) if new_task == None: pass else: new_tasks.append(new_task) del self.tasks_to_do[task_id] tasks_to_remove.append(task_id) self.already_executed.append(task_id) [self.order_list.remove(task) for task in tasks_to_remove] return new_tasks
def process_job_parallel(scheduler, job, nr_cores, nr_iter, parameters = None): Logger.log_level = 2 processes = [] manager = Manager() return_values = manager.dict() extremes = manager.dict() start_time = datetime.datetime.now() for i in range(nr_cores): p = Process(target=worker, args=(i, nr_cores, scheduler, job, nr_iter, return_values, extremes, parameters,)) processes.append(p) p.start() for process in processes: process.join() #reduce results = [] for value in return_values.values(): for entry in value: results.append(entry) min = None max = None for extreme in extremes.values(): if min is None or extreme[0].total_time < min.total_time: min = extreme[0] if max is None or extreme[1].total_time > max.total_time: max = extreme[1] Logger.warning("Min: %s" % min.total_time) Logger.warning("Max: %s" % max.total_time) duration = datetime.datetime.now() - start_time Logger.warning("Simulation complete. Duration: %s" % (duration)) return results, (min,max)
def run_multiple_opt(args, parameter_sets): for idx, param in enumerate(parameter_sets): Logger.warning("running parameter set %s of %s" % (idx, len(parameter_sets))) run_optimization_process(args, param)