def test_makespan(self): assignment = np.array([0, 0, 0]) makespan = support.get_makespan(self.cost, assignment) self.assertEqual(makespan, 0.5) assignment = np.array([4, 4, 4]) makespan = support.get_makespan(self.cost, assignment) self.assertEqual(makespan, 200.0) assignment = np.array([2, 1, 1]) makespan = support.get_makespan(self.cost, assignment) self.assertEqual(makespan, 1.5)
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}')