def test_best_pos_search_recursion(self): schedules = [[t1] * 100 + [t2] * 100 + [t3] * 100] expectations = [( 0, 300, 120 ) # 120 seems to be the result returned by the code and appears to be correct, but I'm not convinced... ] for i, schedule in enumerate(schedules): a = Agent(parameters={ "name": "1", "skill": 0.95, "task_time": 1, "move_speed": 1 }) a.schedule = schedule p_i = a.best_pos_search(tI, range(len(a.schedule) + 1)) p_j = a.best_pos_search(tJ, range(len(a.schedule) + 1)) p_k = a.best_pos_search(tK, range(len(a.schedule) + 1)) p_ijk = p_i[0], p_j[0], p_k[0] #print(p_ijk) assert p_ijk == expectations[i], "Expected {} but got {}".format( expectations[i], p_ijk)
def test_worst_task_idx(self): a = Agent(parameters={ "name": "1", "skill": 0.95, "task_time": 1, "move_speed": 1 }) a.schedule = [t1] * 10 + [tJ] + [t1] * 10 wt = a.worst_task_idx() assert wt == 10, "Should have been {} but was {}".format(10, wt)
def test_best_pos_search_base_case(self): schedules = [[], [tX], [t1, t2, t3]] expectations = [(0, 0, 0), (1, 1, 1), (0, 3, 1)] for i, schedule in enumerate(schedules): a = Agent(parameters={ "name": "1", "skill": 0.95, "task_time": 1, "move_speed": 1 }) a.schedule = schedule p_i = a.best_pos_search(tI, range(len(a.schedule) + 1)) p_j = a.best_pos_search(tJ, range(len(a.schedule) + 1)) p_k = a.best_pos_search(tK, range(len(a.schedule) + 1)) p_ijk = p_i[0], p_j[0], p_k[0] assert p_ijk == expectations[i], "Expected {} but got {}".format( expectations[i], p_ijk)