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

Improve the performance of CQM.fix_variables() #1320

Merged
merged 4 commits into from
Apr 17, 2023

Conversation

arcondello
Copy link
Member

Add the ability to generate a new model when fixing variables rather than acting on the CQM in-place. This is almost always more performant. For instance, see the times for a 1000 variable and 1000 constraint CQM with different numbers of variables fixed.

trials

Closes #1319

@arcondello arcondello requested review from mhlr and randomir and removed request for mhlr April 10, 2023 15:53
Comment on lines 548 to 549
new_constraint.mark_discrete(old_constraint_ptr->marked_discrete() &&
old_constraint_ptr->is_onehot());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we test here if a binary variable that was part of a discrete constraint was fixed above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It ends up being the same complexity for more complicated code. The only case that would help is if a constraint was mis-marked as being discrete and we would now fix that marking. The markers are in general treated as hints so I think that case is fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary from offline conversation, @randomir correctly pointed out that it should be

Suggested change
new_constraint.mark_discrete(old_constraint_ptr->marked_discrete() &&
old_constraint_ptr->is_onehot());
new_constraint.mark_discrete(old_constraint_ptr->marked_discrete() &&
new_constraint.is_onehot());

@arcondello arcondello merged commit 4cfb905 into dwavesystems:main Apr 17, 2023
@arcondello arcondello deleted the fix-variables-copy branch April 17, 2023 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants