def worst_case_nf(input_size, outfile): print('Running a worst case for Next Fit') with open(outfile, 'a') as f: f.write('Running a worst case for Next Fit\n') bad_input_nf = [1 / 2, 1 / (2 * input_size)] * int(math.ceil(input_size / 2)) pack_print_all(bad_input_nf, outfile) pack_and_print(bad_input_nf, first_fit, outfile, False) pack_and_print(bad_input_nf, first_fit, outfile, True)
def test_ptas(input_size, outfile): epses = [0.5, 0.25, 0.1, 0.05, 0.01, 0.001] for eps in epses: set_epsilon(eps) with open(outfile, 'a') as f: f.write('Doing PTAS, eps={}\n'.format(eps)) for i in range(64): pack_and_print(random_list(input_size), ptas_awfd, outfile, True)
def worst_case_ff(input_size, outfile): print('Running a worst case for First Fit') with open(outfile, 'a') as f: f.write('Running a worst case for First Fit\n') one_third = int(math.ceil(input_size / 3)) bad_input_ff = [1 / 7 + 0.001] * one_third + [1 / 3 + 0.001] * one_third + [1 / 2 + 0.001] * one_third pack_print_all(bad_input_ff, outfile) pack_and_print(bad_input_ff, first_fit, outfile, False) pack_and_print(bad_input_ff, first_fit, outfile, True)