def test_check_total_assigned(self): assignment = np.array([4, 4, 4]) tasks = 12 check = support.check_total_assigned(tasks, assignment) self.assertTrue(check) tasks = 13 check = support.check_total_assigned(tasks, assignment) self.assertFalse(check) tasks = 11 check = support.check_total_assigned(tasks, assignment) self.assertFalse(check)
def check_and_store(name, tasks, resources, assignment, cost, lower_limit, upper_limit): """ Checks if the results are correct and stores them in the logger. Parameters ---------- name : string Name of the scheduler tasks : int Number of tasks (tau) resources : int Number of resources (R) assignment : np.array(shape=(resources)) Assignment of tasks to resources cost : np.array(shape=(resources, tasks+1)) Cost functions per resource (C) lower_limit : np.array(shape=(resources), dtype=int) Lower limit of number of tasks per resource upper_limit : np.array(shape=(resources), dtype=int) Upper limit of number of tasks per resource """ cmax = support.get_makespan(cost, assignment) if support.check_total_assigned(tasks, assignment) == False: print(f'-- {name} failed to assign {tasks} tasks to' + f' {resources} resources ({np.sum(assignment)}' + f' were assigned).') if support.check_limits(assignment, lower_limit, upper_limit) == False: print(f'-- {name} failed to respect the lower or upper' + f' limits when assigning {tasks} tasks to' + f' {resources} resources.') logger.store(f'{name},{tasks},{resources},{cmax}')