def test_hadamard_translation_8(self):
		"""
		Tests the translation of the hadamard problem of size 8 to a SAT problem.
		"""
		n = 8
		translation = ha.hadamard_translation(n)
		self.assertNotEqual(bf.Fls(), translation, "Invalid hadamard translation for n = 8, expected not Fls.")
	def test_hadamard_translation_3(self):
		"""
		Tests the translation of the hadamard problem of size 3 to a SAT problem.
		"""
		n = 3
		translation = ha.hadamard_translation(n)
		result = bf.Fls()
		self.assertEqual(result, translation, "Invalid hadamard translation for n = 3, expected Fls.")
Beispiel #3
0
def run_example(n):
	"""
	Helper method that converts the hadamard matrix of size n to a boolean formula and runs the DPLL algorithm on it.
	"""
	print "RUNNING EXAMPLE FOR n = " + str(n)

	translation_start = time.time()
	translation = ha.hadamard_translation(n)
	translation_end = time.time() - translation_start
	print "TRANSLATION OF HADAMARD MATRIX: "
	print translation
	print "TIME NEEDED FOR TRANSLATION: " + str(translation_end)

	dpll_start = time.time()
	solution = dpll.DPLL(translation)
	dpll_end = time.time() - dpll_start
	if solution == False:
		print "Problem is not solvable"
	else:
		print "SOLUTION: " + str(solution)
	print "TIME NEEDED FOR DPLL: " + str(dpll_end)
	print "TOTAL TIME NEEDED: " + str(translation_end + dpll_end)
	print "-----------------------------------------------------------------------------------------------------------------\n"