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.

34 lines
824 B

6 years ago
  1. def readMinisatResult(path):
  2. result = {"assignments": [], "satisfiable": False}
  3. resultFile = open(path)
  4. line = resultFile.readline()
  5. if line.strip() == "SAT":
  6. result["satisfiable"] = True
  7. result["assignments"] = __parseVarAssignments(resultFile.readline())
  8. resultFile.close()
  9. return result
  10. def __parseVarAssignments(line):
  11. assignmentStrings = line.split()
  12. trailer = assignmentStrings.pop()
  13. assignments = []
  14. if trailer == "0":
  15. for assignmentStr in assignmentStrings:
  16. assignment = True if int(assignmentStr) > 0 else False
  17. assignments.append(assignment)
  18. else:
  19. print("Bad format of assignment string:\n %s", line)
  20. return assignments