|
|
- #!/usr/bin/env python3
-
- import util.script as script
- import util.queries as queries
- import dimod
-
- from tqdm import tqdm
-
- def main():
- wmis_siman_results_alpha_num_of_assignments()
- #wmis_siman_results()
-
- def wmis_siman_results():
- db = script.connect_to_instance_pool()
-
- q = queries.WMIS_result_scope_query_raw(db)
- q.query("c45_v[5-45]_1", "wmis_siman_results")
-
- for i in range(2):
- result = q.__next__()
-
- sample_set = queries.read_raw_wmis_sample_set(result["data"])
-
- data = script.analyze_wmis_sample(sample_set.first)
-
- print(data)
-
- def wmis_siman_results_alpha_num_of_assignments():
- edb = script.connect_to_experimetns_db()
- edb_cursor = edb.cursor()
-
- idb = script.connect_to_instance_pool()
-
- q = queries.WMIS_result_scope_query_raw(idb)
- q.query("c42_v[5-84]_1", "wmis_siman_results")
-
- insert_row = ("INSERT INTO c42_v5to84_1_wmis_results "
- "(result_id, "
- " number_of_clauses, "
- " number_of_variables, "
- " number_of_found_assignments, "
- " chain_break_fraction, "
- " num_occurrences, "
- " energy) "
- "VALUES (%s, %s, %s, %s, %s, %s, %s) ")
-
- for result in tqdm(q):
- sample_set = queries.read_raw_wmis_sample_set(result["data"])
-
- data = script.analyze_wmis_sample(sample_set.first)
-
- sat = queries.get_instance_by_id(idb["instances"], result["instance"])
-
- edb_cursor.execute(insert_row, (str(result["_id"]),
- int(sat.getNumberOfClauses()),
- int(sat.getNumberOfVariables()),
- int(data["number_of_assignments"]),
- float(data["chain_break_fraction"]),
- int(data["num_occurrences"]),
- int(data["energy"])))
-
- edb.commit()
- edb_cursor.close()
- edb.close()
-
- if __name__ == "__main__":
- main()
|