Skip to main content

Symbolic QUBO Modeling

Project description

PyPI OS License: MIT

quboify

quboify is an open-source Python package for constructing Quadratic Unconstrained Binary Optimization (QUBO) models from symbolic expressions while preserving symbolic parameters.

The primary use case of quboify is to take a SymPy model, and convert it into QUBO form with a qubovert data structure while maintaining the symbolic expressions such that late-stage adjustments of parameters is possible.

quboify offers only limited links to existing quantum optimization solvers. As these solvers are expected to develop and change in the future, this toolkit offers an extendable solver-independent interface.

quboify was developed at the Institute of Energy Systems Engineering (ICE-1) at Forschungszentrum Jülich GmbH, Germany.

Getting Started

Installation

The authors recommend installation using Pixi:

pixi add quboify

Alternatively from PyPI:

pip install quboify

Usage

The following example showcases the support of potentially problematic variable names and expressions (see a-0-0 and 1e-7) and parameter modification without reconstructing the QUBO (see p).

from quboify import Constraints, ObjectiveFunctions, Problem, Solver, Symbols

variables = Symbols()
constraints = Constraints()
obj_func = ObjectiveFunctions()

a = variables.add_binary_variable("a-0-0")
b = variables.add_discrete_variable("b", [-1, 1, 3])
c = variables.add_continuous_variable("c", -2, 2, 0.25)
p = variables.add_parameter("p")

constraints.add_constraint(variables.encoding_constraints)
constraints.add_constraint("b + c >= 2", variable_precision=True)

obj_func.add_objective_function(a*p + b*c*p + c**2 + 1e-7)

problem = Problem(variables, constraints, obj_func)

solver = Solver(problem)

problem.set_parameters({"p": 2})
solutions = solver.solve_simulated_annealing()
print(f"Best solution: {solutions.best_solution}")
print(f"with objective function value: {solutions.best_solution_objective_values}")

problem.set_parameters({"p": -1})
solutions = solver.solve_simulated_annealing()
print(f"Best solution: {solutions.best_solution}")
print(f"with objective function value: {solutions.best_solution_objective_values}")

Referencing

In case you are quboify in your work, we would be thankful if you referred to it by citing the following publication (also found in paper/paper.md):

to be published

Acknowledgements

The project originated as a fork of mqt-qao. The authors acknowledge the original developers for establishing the foundational concepts on which quboify builds.

The code and paper for this project were written as part of the project “Quantum-based Energy Grids (QuGrids)”, which is receiving funding from the programme “Profilbildung 2022”, an initiative of the Ministry of Culture and Science of the State of North Rhine-Westphalia.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quboify-1.1.1.tar.gz (86.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quboify-1.1.1-py2.py3-none-any.whl (27.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file quboify-1.1.1.tar.gz.

File metadata

  • Download URL: quboify-1.1.1.tar.gz
  • Upload date:
  • Size: 86.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for quboify-1.1.1.tar.gz
Algorithm Hash digest
SHA256 532f359c212f3d0c9e5bf49f575ba7dbd9db8acb408983c41530f1ef79e3aac5
MD5 f3ccfbb3ed1df6c43e4646de4732d9d2
BLAKE2b-256 cffba265d7117a36bb81df2643666e39abfcb33cc6be34f1774130c8f88cfdc8

See more details on using hashes here.

File details

Details for the file quboify-1.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: quboify-1.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for quboify-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9d9e5905ddb20c6758b7c575c0e24cf2736754b62164e8754c7bfd95fc2855f9
MD5 4931364b0ec47bc915f94b706d5fb259
BLAKE2b-256 fae94c9b3c1613f2c622617037135223566559b06fdeab0d2564a8bdfdbdfc49

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page