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

Provide True/False as variable inputs for constraints #53

Open
arcondello opened this issue Aug 14, 2018 · 0 comments
Open

Provide True/False as variable inputs for constraints #53

arcondello opened this issue Aug 14, 2018 · 0 comments

Comments

@arcondello
Copy link
Member

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'])
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

1 participant