Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-zero minimum energy in BQM returned by stitch function #86

Open
conquistador1492 opened this issue May 16, 2019 · 1 comment
Open

Comments

@conquistador1492
Copy link

conquistador1492 commented May 16, 2019

stitch function returns BQM with non-zero energy of ground state for constraint with 1 or 2 variables. In 3 and more variables cases, everything is fine(below I give examples). I'm not sure it's a bug, but zero energy might be useful if somebody combines many different constraints. Then, they may be assured that the final state has zero energy.

csp0 = ConstraintSatisfactionProblem(BINARY)
csp0.add_constraint(lambda a: a, ['a'])

csp1 = ConstraintSatisfactionProblem(BINARY)
csp1.add_constraint(lambda a, b: a == b, ['a', 'b'])

csp2 = ConstraintSatisfactionProblem(BINARY)
csp2.add_constraint(lambda a, b: a & b, ['a', 'b'])

csp3 = ConstraintSatisfactionProblem(BINARY)
csp3.add_constraint(lambda a, b, c: a == b == c, ['a', 'b', 'c'])

csp4 = ConstraintSatisfactionProblem(BINARY)
csp4.add_constraint(lambda a, b, c: a == b == c, ['a', 'b', 'c'])

csp5 = ConstraintSatisfactionProblem(BINARY)
csp5.add_constraint(lambda a, b, c, d: (a & b) & c | d, ['a', 'b', 'c', 'd'])

for csp in [csp0, csp1, csp2, csp3, csp4, csp5]:
    bqm = stitch(csp)
    response = SimulatedAnnealingSampler().sample(bqm, num_reads=100)
    print(sorted(response.data(), key=lambda x: x.energy)[0].energy)

As a result, we get:

-1.0
-1.0
-2.0
0.0
0.0
-2.0000000011677344e-07

Environment

  • OS: Ubuntu 18.04.2 LTS
  • Python version: 3.6.7
  • dwavebinarycsp: 0.0.11
@m3ller
Copy link
Contributor

m3ller commented May 21, 2019

stitch(..) calls on dwavesystems/penaltymodel repo to help build the bqm. The penaltymodel is interested in making the gap between excited states and ground states as large as possible, but currently, it does not make the effort to shift the bqm so that the ground is always at 0.

Hence, this issue is not a bug, but it would be a great candidate for code enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants