Skip to content
This repository was archived by the owner on Sep 24, 2025. It is now read-only.
This repository was archived by the owner on Sep 24, 2025. It is now read-only.

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

Description

@conquistador1492

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions