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.

67 lines
2.1 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. #!/usr/bin/env python3
  2. import util.script as script
  3. import util.queries as queries
  4. import dimod
  5. def main():
  6. wmis_siman_results_alpha_num_of_assignments()
  7. #wmis_siman_results()
  8. def wmis_siman_results():
  9. db = script.connect_to_instance_pool()
  10. q = queries.WMIS_result_scope_query_raw(db)
  11. q.query("c45_v[5-45]_1", "wmis_siman_results")
  12. for i in range(2):
  13. result = q.__next__()
  14. sample_set = queries.read_raw_wmis_sample_set(result["data"])
  15. data = script.analyze_wmis_sample(sample_set.first)
  16. print(data)
  17. def wmis_siman_results_alpha_num_of_assignments():
  18. edb = script.connect_to_experimetns_db()
  19. edb_cursor = edb.cursor()
  20. idb = script.connect_to_instance_pool()
  21. q = queries.WMIS_result_scope_query_raw(idb)
  22. q.query("c42_v[5-42]_1", "wmis_siman_results")
  23. insert_row = ("INSERT INTO c42_v5to42_1_wmis_results "
  24. "(result_id, "
  25. " number_of_clauses, "
  26. " number_of_variables, "
  27. " number_of_found_assignments, "
  28. " chain_break_fraction, "
  29. " num_occurrences, "
  30. " energy) "
  31. "VALUES (%s, %s, %s, %s, %s, %s, %s) ")
  32. for result in q:
  33. sample_set = queries.read_raw_wmis_sample_set(result["data"])
  34. data = script.analyze_wmis_sample(sample_set.first)
  35. sat = queries.get_instance_by_id(idb["instances"], result["instance"])
  36. edb_cursor.execute(insert_row, (str(result["_id"]),
  37. int(sat.getNumberOfClauses()),
  38. int(sat.getNumberOfVariables()),
  39. int(data["number_of_assignments"]),
  40. float(data["chain_break_fraction"]),
  41. int(data["num_occurrences"]),
  42. int(data["energy"])))
  43. print(data)
  44. edb.commit()
  45. edb_cursor.close()
  46. edb.close()
  47. if __name__ == "__main__":
  48. main()