You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3 KiB

6 years ago
6 years ago
6 years ago
  1. #!/usr/bin/env python3
  2. from util import kSAT
  3. from util import minisat as mSatU
  4. import argparse
  5. def main():
  6. parser = argparse.ArgumentParser()
  7. parser.add_argument("-i", "--instance", help="instance file, has to be in DIMACS format", type=str)
  8. parser.add_argument("-r", "--result", help="minisat result file", type=str)
  9. args = parser.parse_args()
  10. instancePath = args.instance
  11. if instancePath == None:
  12. instancePath = str(input("Instance file: "))
  13. minisatResultFile = args.result
  14. if minisatResultFile == None:
  15. minisatResultFile = str(input("Minisat result file: "))
  16. print("Checking...")
  17. print("Instance:\t%s" % instancePath)
  18. print("Minisat result:\t%s" % minisatResultFile)
  19. checkStr = __checkResult(instancePath, minisatResultFile)
  20. print("check:\t\t%s" % checkStr)
  21. def __checkResult(instancePath, minisatResultFile):
  22. sat = kSAT.kSAT()
  23. sat.readDIMACS(instancePath)
  24. minisatResult = mSatU.readMinisatResult(minisatResultFile)
  25. if minisatResult["satisfiable"]:
  26. if sat.checkAssignment(minisatResult["assignments"]):
  27. return "results do match"
  28. else:
  29. return "results do NOT match"
  30. else:
  31. return "unsatisfiable"
  32. if __name__ == "__main__":
  33. main()