Deterministically ordered `BinaryPolynomial`
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.