def test_scheduling_with_ratio_sort(self): input = { 'num_jobs': 4, 'jobs': [(2, 1), (8, 5), (5, 3), (3, 2)], } scheduled_jobs = schedule(input, RATIO_SORT) self.assertListEqual(scheduled_jobs, [(2, 1), (5, 3), (8, 5), (3, 2)])
def test_get_weighted_completion_times_with_diff_sort(self): input = { 'num_jobs': 4, 'jobs': [(2, 1), (8, 5), (5, 3), (3, 2)], } scheduled_jobs = schedule(input, DIFF_SORT) result = get_weighted_completion_times(scheduled_jobs) self.assertEqual(result, 40+40+30+22)
def test_get_weighted_completion_times_with_ratio_sort(self): input = { 'num_jobs': 4, 'jobs': [(2, 1), (8, 5), (5, 3), (3, 2)], } scheduled_jobs = schedule(input, RATIO_SORT) result = get_weighted_completion_times(scheduled_jobs) self.assertEqual(result, 2+20+72+33)
def assign(file_path_experts, file_path_clients): """ Assign given experts given to given clients. REQUIRES: fileNameExperts, fileNameClients are str, with the paths of the files representing the list of experts and clients, respectively, following the format indicated in the project. ENSURES: Two output files, respectively, with the listing of schedules tasks and the updated listing of experts, following the format and naming convention indicated in the project. """ clients_content = FR.readClientsFile(file_path_clients) experts_content = FR.readExpertsFile(file_path_experts) copy_clients_content = copy.deepcopy(clients_content) copy_experts_content = copy.deepcopy(experts_content) clients_header = copy_clients_content.pop(C.HEADER_INDEX) experts_header = copy_experts_content.pop(C.HEADER_INDEX) #exception treatment checkConsistencyHeaderFileName(clients_header, file_path_clients) checkConsistencyHeaderFileName(experts_header, file_path_experts) checkConsistencyBetweenFiles(file_path_clients, clients_header, file_path_experts, experts_header) updated_schedule_header = FW.updateHeader(clients_header, "Schedule") new_schedule_file_name = FW.createFileName(updated_schedule_header) updated_experts_header = FW.updateHeader(experts_header, "Experts") new_experts_file_name = FW.createFileName(updated_experts_header) current_date = updated_schedule_header[C.HEADER_DATE_INDEX] current_time = updated_schedule_header[C.HEADER_TIME_INDEX] scheduled_content, updated_experts_content = S.schedule( copy_clients_content, copy_experts_content, current_date, current_time) scheduled_content.insert(C.HEADER_INDEX, updated_schedule_header) updated_experts_content.insert(C.HEADER_INDEX, updated_experts_header) # one could also put file_path_clients (assuming they are in the same folder). output_directory = FW.createDirectory(file_path_experts) FW.writeSchedule(new_schedule_file_name, scheduled_content, output_directory) FW.writeExpertsFile(new_experts_file_name, updated_experts_content, output_directory)