Adding constraints to BQM model?
Is there easy way to add constraints to binary BQM (or Ising) after you have created it using parameters a (h) and b (J)?
I have a problem in which binary variables must not take certain combination of values.
—
Tomas Ukkonen
Comments
I create individual Q matrices for each constraint for inspection and add them up to create a final "all baked in" qubo.
Hi Thomas,
The code example here shows how to add constraint to an existing BQM using bqm.update(other_bqm) function.
You can add in constraints to any existing BQM (QUBO or, Ising) but sometimes, you might end up accidently overwriting the existing constraints or objective (as seen here).
Alternatively, as Mario suggested, you can build out the BQM for all the components (objective and constraints) and then combine them into one BQM.
Here are some additional helpful resources on it:
I hope this helps!
Please let me know if you have any questions.
Please sign in to leave a comment.