Metadata-Version: 2.4
Name: quboify
Version: 1.0.2
Summary: Symbolic QUBO Modeling
Author-email: Henri Karhula <h.karhula@fz-juelich.de>
License: MIT License
        
        Copyright (c) 2025 Henri Karhula
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: QUBO,Sympy,optimization,quantum-computing
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
Requires-Dist: qubovert>=1.2.5
Requires-Dist: sympy
Description-Content-Type: text/markdown

[![PyPI](https://img.shields.io/pypi/v/mqt.qao?logo=pypi&style=flat-square)](https://pypi.org/project/quboify/)
![OS](https://img.shields.io/badge/os-linux%20%7C%20macos%20%7C%20windows-blue?style=flat-square)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/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](https://pixi.prefix.dev/latest/):

```console
pixi add quboify
```

Alternatively from [PyPI](https://pypi.org/project/quboify/):

```console
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`).

```python
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 + (b+p)*c + 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`):

```bibtex
to be published
```

## Acknowledgements

The project originated as a fork of [`mqt-qao`](https://github.com/cda-tum/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.