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

Deterministically ordered BinaryPolynomial #1327

Open
hbarovertwo opened this issue May 9, 2023 · 0 comments
Open

Deterministically ordered BinaryPolynomial #1327

hbarovertwo opened this issue May 9, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@hbarovertwo
Copy link
Member

Application
The terms of a BinaryPolynomial are implemented with frozenset.
Python sets are unordered in a non-deterministic way. This leads to some interesting behavior that propagates to the related functions, reduce_binary_polynomial and make_quadratic_cqm.

Within a python invocation, it is possible to produce the same CQM model repeatedly, given the same BinaryPolynomial object.
This changes from run to run though, see this post on stackoverflow. This can lead to CQM models with different variables and constraints given the same BinaryPolynomial, or different reduced terms and constraints being returned from reduce_binary_polynomial.

It would be useful to be able to produce the same reduction results from run to run, rather than having to fix an environment variable to force the behavior.

Proposed Solution
Rework BinaryPolynomial and related functions to avoid sets - or possibly use something like an ordered set instead.

Alternatives Considered
Setting the environment variable PYTHONHASHSEED makes set iteration deterministic. This has to be done prior to invoking Python.

@arcondello arcondello added the enhancement New feature or request label May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants