def test_k_resolutions_lower_constraints_list_simple(): ans_ground = [[1, 3], [2, 2]] ans = k_resolutions_lower_constraints_list(4, [1, 2]) assert_equal(len(ans), len(ans_ground)) for i in range(len(ans)): assert_true(ans[i] in ans_ground)
def test_k_resolutions_lower_constraints_list_simple_2(): ans_ground = [[1, 2, 7], [1, 3, 6], [1, 4, 5], [1, 5, 4], [1, 6, 3], [2, 2, 6], [2, 3, 5], [2, 4, 4], [2, 5, 3], [3, 2, 5], [3, 3, 4], [3, 4, 3], [4, 2, 4], [4, 3, 3], [5, 2, 3]] ans = k_resolutions_lower_constraints_list(10, [1, 2, 3]) assert_equal(len(ans), len(ans_ground)) for i in range(len(ans)): assert_true(ans[i] in ans_ground)
print '\n' + str(k) + '-resolutions of ' + str(n) + ', unconstrained:' print 'closed form = ' + str(closed_form) print 'counting the solutions = ' + str(counting_solutions) print 'It is ' + str(closed_form == counting_solutions) + ' that the closed form equals the direct enumerations. \n' ######################################### # k -resolutions of n lower constraints # ######################################### n_lower = 15 t_lower = [3, 4, 1, 2] k_lower = len(t_lower) closed_form = number_of_k_resolutions_lower_constraints(n_lower, t_lower) counting_solutions = len(k_resolutions_lower_constraints_list(n_lower, t_lower)) print '\n' + str(k_lower) + '-resolutions of ' + str(n_lower) + ', with lower constraints ' + str(t_lower) + ':' print 'closed form = ' + str(closed_form) print 'counting the solutions = ' + str(counting_solutions) print 'It is ' + str(closed_form == counting_solutions) + ' that the closed form equals the direct enumerations. \n' ######################################### # k -resolutions of n upper constraints # ######################################### n_upper = 10 t_upper = [4, 3, 1, 5, 5] # [5, 7, 8, 5, 4, 2] k_upper = len(t_upper) time_results = [0.0] * 2
def test_k_resolutions_lower_constraints_list_simple_extreme(): ans_ground = [] ans = k_resolutions_lower_constraints_list(4, [1, 2, 3]) assert_equal(len(ans), len(ans_ground))