|
|
@ -7,8 +7,10 @@ import dimod |
|
|
|
from tqdm import tqdm |
|
|
|
|
|
|
|
def main(): |
|
|
|
#wmis_results() |
|
|
|
wmis_siman_results_alpha_num_of_assignments() |
|
|
|
#wmis_siman_results() |
|
|
|
#minisat_runs() |
|
|
|
|
|
|
|
def wmis_siman_results(): |
|
|
|
db = script.connect_to_instance_pool() |
|
|
@ -32,17 +34,19 @@ def wmis_siman_results_alpha_num_of_assignments(): |
|
|
|
idb = script.connect_to_instance_pool() |
|
|
|
|
|
|
|
q = queries.WMIS_result_scope_query_raw(idb) |
|
|
|
q.query("c42_v[5-84]_1", "wmis_siman_results") |
|
|
|
q.query("c42_v[5-84]_1", "wmis_qbsolv_results") |
|
|
|
|
|
|
|
insert_row = ("INSERT INTO c42_v5to84_1_wmis_results " |
|
|
|
insert_row = ("INSERT INTO c42_v5to84_1_wmis_qbsolv_results " |
|
|
|
"(result_id, " |
|
|
|
" instance_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) ") |
|
|
|
" energy, " |
|
|
|
" satisfiable) " |
|
|
|
"VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s) ") |
|
|
|
|
|
|
|
for result in tqdm(q): |
|
|
|
sample_set = queries.read_raw_wmis_sample_set(result["data"]) |
|
|
@ -51,17 +55,77 @@ def wmis_siman_results_alpha_num_of_assignments(): |
|
|
|
|
|
|
|
sat = queries.get_instance_by_id(idb["instances"], result["instance"]) |
|
|
|
|
|
|
|
model = script.majority_vote_sample(sample_set.first.sample) |
|
|
|
|
|
|
|
isSatisfiable = sat.checkAssignment(model) |
|
|
|
|
|
|
|
edb_cursor.execute(insert_row, (str(result["_id"]), |
|
|
|
str(result["instance"]), |
|
|
|
int(sat.getNumberOfClauses()), |
|
|
|
int(sat.getNumberOfVariables()), |
|
|
|
int(data["number_of_assignments"]), |
|
|
|
float(data["chain_break_fraction"]), |
|
|
|
int(data["num_occurrences"]), |
|
|
|
int(data["energy"]))) |
|
|
|
int(data["energy"]), |
|
|
|
isSatisfiable)) |
|
|
|
|
|
|
|
edb.commit() |
|
|
|
edb_cursor.close() |
|
|
|
edb.close() |
|
|
|
|
|
|
|
def minisat_runs(): |
|
|
|
edb = script.connect_to_experimetns_db() |
|
|
|
edb_cursor = edb.cursor(); |
|
|
|
|
|
|
|
idb = script.connect_to_instance_pool() |
|
|
|
|
|
|
|
runs = queries.Minisat_run_scope_query_raw(idb) |
|
|
|
runs.query("c42_v[5-84]_1", "minisat_runs") |
|
|
|
|
|
|
|
insert_row = ("INSERT INTO c42_v5to84_1_minisat_runs " |
|
|
|
"(run_id, " |
|
|
|
" instance_id, " |
|
|
|
" satisfiable) " |
|
|
|
"VALUES (%s, %s, %s) ") |
|
|
|
|
|
|
|
for run in tqdm(runs): |
|
|
|
data = script.analyde_minisat_run(run) |
|
|
|
|
|
|
|
edb_cursor.execute(insert_row, (str(run["_id"]), |
|
|
|
str(run["instance"]), |
|
|
|
int(data["satisfiable"]))) |
|
|
|
|
|
|
|
edb.commit() |
|
|
|
edb_cursor.close() |
|
|
|
edb.close() |
|
|
|
|
|
|
|
def wmis_results(): |
|
|
|
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_qbsolv_results") |
|
|
|
|
|
|
|
for i in range(501): |
|
|
|
q.__next__() |
|
|
|
|
|
|
|
res = q.__next__() |
|
|
|
|
|
|
|
sample_set = queries.read_raw_wmis_sample_set(res["data"]) |
|
|
|
|
|
|
|
|
|
|
|
model = script.majority_vote_sample(sample_set.first.sample) |
|
|
|
|
|
|
|
sat = queries.get_instance_by_id(idb["instances"], res["instance"]) |
|
|
|
|
|
|
|
print(model) |
|
|
|
|
|
|
|
print(sat.getNumberOfVariables()) |
|
|
|
print(sat.checkAssignment(model)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
main() |