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