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

cqm.to_hash() #1306

Open
hsadeghidw opened this issue Jan 23, 2023 · 1 comment
Open

cqm.to_hash() #1306

hsadeghidw opened this issue Jan 23, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@hsadeghidw
Copy link
Contributor

Application
Often, we need to store the fingerprint of a CQM object. This may be useful when one needs to store a CQM object in memory or on disk or retrieve the result of previously solved CQM problems. Having a hash value that is sensitive to the values of all biases and constraints will make it very convenient to give a unique label to CQMs. I don't know if it's possible/useful to decide if it's also sensitive to labels, but I will personally always choose to be sensitive to labels

Proposed Solution

import hashlib

def _to_hash(cqm):
    with cqm.to_file() as f:
        return hashlib.sha1(f.read()).hexdigest()

Alternatives Required
The method above is expensive and creates copies of the CQM object.

Additional Context
The main use case to consider here is when a large problem is broken into smaller problems and many problems are submitted in parallel. In case any of them fail, a restart would ideally load previously solved problems and resubmit the failed ones. This may actually end up being a feature on its own. MultiCQMSampler?

@arcondello arcondello added the enhancement New feature or request label Jan 23, 2023
@boothby
Copy link

boothby commented Jan 23, 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

3 participants