dwavesystems / dimod

A shared API for QUBO/Ising samplers.
https://docs.ocean.dwavesys.com/en/stable/docs_dimod/
Apache License 2.0
119 stars 78 forks source link

Integration with Pyomo (or similar) #1232

Open gilirosenberg12 opened 2 years ago

gilirosenberg12 commented 2 years ago

Application I want to solve my ILP/QP with multiple solvers, including (but not limited) to the QA. I'd much rather use a single piece of code for formulating the problem. For example, via a standard interface like Pyomo. However, I cannot do that for the QA - I need to reformulate the problem using dimod (or another library).

Proposed Solution I'm suggesting to add an integration with Pyomo, or a similar library that supports solving non-linear integer optimization problems. I should be able to write code to formulate my optimization problem only once, and solve it with various common conventional solvers like Gurobi, CPLEX, XPRESS, etc., as well as with the QA.

Alternatives Considered Using CQM directly - the existence of CQM makes this relatively easy. However, it introduces redundancy, which can be a source of errors, as well as requiring increased effort to test, validate, and maintain the codebase.

arcondello commented 2 years ago

Agree that would be useful. In the mean time, we do support lp files which can serve as an intermediate representation.

I believe you can create an LP file using pyomo and then convert to a dimod CQM

cqm = dimod.lp.load('example.lp')

See also https://github.com/dwavesystems/dimod/issues/1228 for another format we'd like to support.

gilirosenberg12 commented 2 years ago

Thanks, @arcondello I wasn't aware of this option, that should work nicely for now! But still it would be nice to have a more direct integration, to avoid the overhead of writing to a file and reading from it...

vpranjal commented 8 months ago

Very much agree with this request - would love to use an integrated approach with Pyomo and pass the problem to QA. CQM might enforce that no cubic or higher order terms be present in the formulation to start with. Might be generally be usable for MILP/ LPs/ QPs solvable by CQM.