prepared qpu solving
This commit is contained in:
@@ -16,3 +16,12 @@ def negate_qubo(qubo):
|
||||
negative_qubo[coupler] = -1 * energy
|
||||
|
||||
return negative_qubo
|
||||
|
||||
def create_qpu_solver_nxgraph(solver):
|
||||
graph = nx.Graph()
|
||||
|
||||
graph.name = solver.id
|
||||
|
||||
graph.add_edges_from(solver.edges)
|
||||
|
||||
return graph
|
||||
|
@@ -398,6 +398,9 @@ def read_raw_qubo(raw_qubo):
|
||||
def read_raw_embedding(raw_embedding):
|
||||
emb = {}
|
||||
|
||||
if "embedding" in raw_embedding:
|
||||
raw_embedding = raw_embedding["embedding"]
|
||||
|
||||
for entry in raw_embedding:
|
||||
emb[tuple(entry[0])] = entry[1]
|
||||
|
||||
|
@@ -116,12 +116,12 @@ class Random_logistic_variable_distribution:
|
||||
min_variables,
|
||||
max_variables,
|
||||
alpha_point_of_interest,
|
||||
steepnesss):
|
||||
steepness):
|
||||
self.__number_of_clauses = number_of_clauses
|
||||
self.__min_variables = min_variables
|
||||
self.__max_variables = max_variables
|
||||
self.__alpha_point_of_interest = alpha_point_of_interest
|
||||
self.__steepnesss = steepnesss
|
||||
self.__steepness = steepness
|
||||
|
||||
def random(self):
|
||||
number_of_variables = 0
|
||||
@@ -131,7 +131,7 @@ class Random_logistic_variable_distribution:
|
||||
|
||||
alpha = inv_logistic(random.random(),
|
||||
1,
|
||||
self.__steepnesss,
|
||||
self.__steepness,
|
||||
self.__alpha_point_of_interest)
|
||||
|
||||
number_of_variables = int(self.__number_of_clauses / alpha)
|
||||
@@ -140,6 +140,17 @@ class Random_logistic_variable_distribution:
|
||||
|
||||
def inv_logistic(x, L, k, x0):
|
||||
return math.log(math.pow(x / (L-x), 1/k)) + x0
|
||||
|
||||
def create_random_logistic_pool(logistic_variable_distr_params, number_of_instances,
|
||||
instance_params):
|
||||
|
||||
logist_distr = Random_logistic_variable_distribution(**logistic_variable_distr_params)
|
||||
|
||||
rnd_range = Random_range(logist_distr, number_of_instances)
|
||||
|
||||
param_range = Instance_parameter_variable_range(instance_params, rnd_range)
|
||||
|
||||
return Random_instance_pool(param_range)
|
||||
|
||||
def test():
|
||||
sns.set()
|
||||
|
@@ -7,12 +7,14 @@ import mysql.connector
|
||||
import networkx as nx
|
||||
from . import queries
|
||||
from . import graph
|
||||
from . import SAT2QUBO
|
||||
import minorminer
|
||||
from tqdm import tqdm
|
||||
import numpy as np
|
||||
import random
|
||||
import sys
|
||||
|
||||
|
||||
def readConfig(configFilePath):
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
@@ -177,6 +179,15 @@ def write_qubo_to_pool_db(collection, qubo, sat_instance_id):
|
||||
|
||||
collection.insert_one(doc)
|
||||
|
||||
def create_wmis_qubos_for_scope(db, scope):
|
||||
instances = queries.Instance_scope_query(db)
|
||||
instances.query(scope)
|
||||
|
||||
for instance, instance_id in instances:
|
||||
qubo = SAT2QUBO.WMISdictQUBO(instance)
|
||||
|
||||
write_qubo_to_pool_db(db["wmis_qubos"], qubo, instance_id)
|
||||
|
||||
def __qubo_to_JSON(qubo):
|
||||
quboJSON = []
|
||||
|
||||
@@ -295,7 +306,7 @@ def find_wmis_embeddings_for_scope(db, scope, solver_graph):
|
||||
percentage))
|
||||
print("{} new embeddigns found".format(new_embeddings_found))
|
||||
|
||||
def save_simulated_annealing_result(collection, result, solver_input, emb_list_index):
|
||||
def save_sample_set(collection, result, solver_input, emb_list_index, run):
|
||||
doc = {}
|
||||
|
||||
doc["data"] = result.to_serializable()
|
||||
@@ -304,9 +315,13 @@ def save_simulated_annealing_result(collection, result, solver_input, emb_list_i
|
||||
"embedding_id": solver_input["embeddings_id"],
|
||||
"list_index": emb_list_index
|
||||
}
|
||||
doc["run"] = run
|
||||
|
||||
collection.insert_one(doc)
|
||||
|
||||
def save_qpu_result():
|
||||
doc = {}
|
||||
|
||||
def analyze_wmis_sample(sample):
|
||||
data = {}
|
||||
|
||||
|
Reference in New Issue
Block a user