Sitelet https://github.com/dwavesystems/dwavebinarycsp/issues/53
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.

Provide True/False as variable inputs for constraints #53

Description

@arcondello

Application
Sometimes I want to create a constraint for which I already know the values for some of the variables. I can create the constraint and then immediately fix the variable after, but it might be nice to do it on creation (also can memory/time).

Proposed Solution
I would like to be able to provide boolean values in the place of variables. This would be equivalent to fixing them.

csp = dwavebinarycsp.ConstraintSatisfactionProblem(dwavebinarycsp.BINARY)

def and_gate(in0, in1, out):
    return (in0 and in1) == out

csp.add_constraint(and_gate, ['a', 'b', False])

In this case the constraint would be the identical to

csp = dwavebinarycsp.ConstraintSatisfactionProblem(dwavebinarycsp.BINARY)

def nand(in0, in1):
    return not (in0 and in1)

csp.add_constraint(nand, ['a', 'b'])

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