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.

60 lines
1.8 KiB

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