# BQM inequality constraint

Hi everyone,

I formulated an optimization problem as following:

How can I re-formulate inequality constraints to be able to embed them for quantum annealer?

Hi everyone,

I formulated an optimization problem as following:

How can I re-formulate inequality constraints to be able to embed them for quantum annealer?

## Comments

Mohammad D(Report)Hi,

I hope you find the following resources helpful.

Learning Resources in Leap

Getting Started with D-Wave Solvers

D-Wave Problem-Solving Handbook

Angela S(Report)Hi @Mohammad, I am following up on this topic as I am interest too. At your links I could only find examples for equality constraints. What about the inequality constraints? How can we embed them for quantum annealer?

Thank you!

Mohammad D(Report)Hi,

For BQM, inequality constraints can be reduced to equality constraints by introducing slack variables.

more info: https://docs.dwavesys.com/docs/latest/handbook_reformulating.html?highlight=inequality#constraints-linear-inequality-penalty-functions

You can use BQM

.add_linear_inequality_constraint()method to add a linear inequality constraint as a quadratic objective. Which calculates and returns the slack terms.more info: https://docs.ocean.dwavesys.com/en/stable/docs_dimod/reference/generated/dimod.binary.BinaryQuadraticModel.add_linear_inequality_constraint.html#

Angela S(Report)Thank you Mohammad D!

If I have understood well, BQM .add_linear_inequality_constraint() accepts constraints that are already formulated as QUBOs. In my case, my constraints are defined in a generic format, i.e. as an arithmetic expression (something that is accepted by CQM). So, my problem is to convert this expression to a BQM that can be added as a penalty term to the 'composite' BQM.

I tried to set my problem directly as a CQM and then convert the CQM to a BQM to sample it with DWaveSampler, but the process is terribly slow as my problem is a large one (90 x 90000 variables). That is why I was thinking to individually convert each constraint (together with the objective) to a BQM and then add it to the 'composite' BQM.

Maybe there is a better strategy for this, but I do not know.

Thank you,

Angela

Ed C(Report)Angela,

While not a direct answer to your question, you may get some ideas by watching this presentation from Victoria Goliber, "Using NumPy for Large Quadratic Models", where she discusses some techniques for building for large quadratic models, which are faster than using the conventional ways of building them.

https://youtu.be/jTDnGox0c9Y?t=5970

Ed

Please sign in to leave a comment.