Skip to content

Commit

Permalink
ising renumeration files
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsmierz committed Jul 11, 2024
1 parent 89d5187 commit 8eeade2
Show file tree
Hide file tree
Showing 19 changed files with 575,336 additions and 4 deletions.
7 changes: 3 additions & 4 deletions AGV_quantum/quadratic_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def to_bqm_qubo_ising(self, pdict=None):
self.ising = pyqubo_model.to_ising(feed_dict=pdict)
self.bqm = pyqubo_model.to_bqm(feed_dict=pdict)

def interpreter(sampleset: dimod.SampleSet):
def interpreter(sampleset: dimod.SampleSet, vartype: str):
"""This is an interpreter function for binary quadratic model. It decodes the binary variables in the sample back to integer variables using pyqubo
:param sampleset: Sampleset to analyze
Expand All @@ -103,7 +103,7 @@ def interpreter(sampleset: dimod.SampleSet):
energies = [d.energy for d in sampleset.data()]
for sample in sampleset.samples():
decoded = pyqubo_model.decode_sample(
dict(sample), vartype="BINARY", feed_dict=pdict
dict(sample), vartype=vartype, feed_dict=pdict
)

decoded_dict = {**decoded.subh, **decoded.sample}
Expand All @@ -113,8 +113,7 @@ def interpreter(sampleset: dimod.SampleSet):
return dimod.SampleSet.from_samples(
dimod.as_samples(result), "INTEGER", energy=energies)


self.interpreter = lambda ss: interpreter(ss)
self.interpreter = lambda ss, var: interpreter(ss, var)

@staticmethod
def _get_slack_ub(model_vars: list, coefs: list, offset: int) -> int:
Expand Down
Loading

0 comments on commit 8eeade2

Please sign in to comment.