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.

38 lines
1.0 KiB

6 years ago
6 years ago
6 years ago
  1. #!/usr/bin/env python3
  2. from util.kSAT import kSAT
  3. from util import SATquboResult
  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="WMIS qubo result file", type=str)
  9. args = parser.parse_args()
  10. instancePath = args.instance
  11. if instancePath == None:
  12. instancePath = str(input("Instance file: "))
  13. resultFile = args.result
  14. if resultFile == None:
  15. resultFile = str(input("WMIS qubo result file: "))
  16. __verify(instancePath, resultFile)
  17. def __verify(instancePath, resultFile):
  18. sat = kSAT()
  19. sat.readDIMACS(instancePath)
  20. assignments = SATquboResult.readAssignmentsFromFile(resultFile)
  21. evaluations = sat.evaluate(assignments)
  22. for i in range(len(assignments)):
  23. print(assignments[i], evaluations[i])
  24. if __name__ == "__main__":
  25. main()