Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juliaqubo/toqubo.jl
๐ฆ JuMP ToQUBO Automatic Reformulation
https://github.com/juliaqubo/toqubo.jl
julia jump optimization qubo
Last synced: about 23 hours ago
JSON representation
๐ฆ JuMP ToQUBO Automatic Reformulation
- Host: GitHub
- URL: https://github.com/juliaqubo/toqubo.jl
- Owner: JuliaQUBO
- License: other
- Created: 2021-11-22T12:26:58.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-09-26T00:04:07.000Z (about 2 months ago)
- Last Synced: 2024-10-06T18:05:54.579Z (about 1 month ago)
- Topics: julia, jump, optimization, qubo
- Language: Julia
- Homepage: https://juliaqubo.github.io/ToQUBO.jl/
- Size: 1.81 MB
- Stars: 27
- Watchers: 10
- Forks: 2
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Citation: CITATION.bib
Awesome Lists containing this project
README
# ToQUBO.jl ๐ฅ๐ฉ๐ช๐ฆ
## Introduction
ToQUBO.jl is a Julia package to reformulate general optimization problems into [QUBO](https://en.wikipedia.org/wiki/Quadratic_unconstrained_binary_optimization) (Quadratic Unconstrained Binary Optimization) instances. This tool aims to convert a broad range of [JuMP](https://github.com/jump-dev/JuMP.jl) problems for straightforward application in many physics and physics-inspired solution methods whose normal optimization form is equivalent to the QUBO. These methods include quantum annealing, quantum gate-circuit optimization algorithms (Quantum Optimization Alternating Ansatz, Variational Quantum Eigensolver), other hardware-accelerated platforms, such as Coherent Ising Machines and Simulated Bifurcation Machines, and more traditional methods such as simulated annealing. During execution, ToQUBO.jl encodes both discrete and continuous variables, maps constraints, and computes their penalties, performing a few model optimization steps along the process. A simple interface to connect various annealers and samplers as QUBO solvers is defined in [QUBODrivers.jl](https://github.com/psrenergy/QUBODrivers.jl).ToQUBO.jl was written as a [MathOptInterface](https://github.com/jump-dev/MathOptInterface.jl) (MOI) layer that automatically maps between input and output models, thus providing a smooth JuMP modeling experience.
## Getting Started
### Installation
ToQUBO is available via Julia's Pkg:```julia
julia> using Pkgjulia> Pkg.add("ToQUBO")
```### Simple Example
```julia
using JuMP
using ToQUBO
using QUBODriversmodel = Model(() -> ToQUBO.Optimizer(ExactSampler.Optimizer))
@variable(model, x[1:3], Bin)
@constraint(model, 0.3*x[1] + 0.5*x[2] + 1.0*x[3] <= 1.6)
@objective(model, Max, 1.0*x[1] + 2.0*x[2] + 3.0*x[3])optimize!(model)
for i = 1:result_count(model)
xi = value.(x, result = i)
yi = objective_value(model, result = i)println("f($xi) = $yi")
end
```## List of Interpretable Constraints
Below, we present a list containing all[โด](#4) MOI constraint types and their current reformulation support by ToQUBO.### Linear constraints
| Mathematical Constraint | MOI Function | MOI Set | Status |
| -------------------------------------------- | -------------------- | ------------ | :----: |
| $\vec{a}' \vec{x} \le \beta$ | ScalarAffineFunction | LessThan | โ๏ธ |
| $\vec{a}' \vec{x} \ge \alpha$ | ScalarAffineFunction | GreaterThan | โป๏ธ |
| $\vec{a}' \vec{x} = \beta$ | ScalarAffineFunction | EqualTo | โ๏ธ |
| $\alpha \le \vec{a}' \vec{x} \le \beta$ | ScalarAffineFunction | Interval | โป๏ธ |
| $x_i \le \beta$ | VariableIndex | LessThan | โ๏ธ |
| $x_i \ge \alpha$ | VariableIndex | GreaterThan | โ๏ธ |
| $x_i = \beta$ | VariableIndex | EqualTo | โ๏ธ |
| $\alpha \le x_i \le \beta$ | VariableIndex | Interval | โ๏ธ |
| $A \vec{x} + b \in \mathbb{R}_{+}^{n}$ | VectorAffineFunction | Nonnegatives | โป๏ธ |
| $A \vec{x} + b \in \mathbb{R}_{-}^{n}$ | VectorAffineFunction | Nonpositives | โป๏ธ |
| $A \vec{x} + b = 0$ | VectorAffineFunction | Zeros | โป๏ธ |### Conic constraints
| Mathematical Constraint | MOI Function | MOI Set | Status |
| ----------------------------------------------------------------------------------------------------------------- | -------------------- | -------------------------------- | :----: |
| $\left\lVert{}{A \vec{x} + b}\right\rVert{}_{2} \le \vec{c}' \vec{x} + d$ | VectorAffineFunction | SecondOrderCone | ๐ |
| $y \ge \left\lVert{}{\vec{x}}\right\rVert{}_{2}$ | VectorOfVariables | SecondOrderCone | ๐ |
| $2 y z \ge \left\lVert{}{\vec{x}}\right\rVert{}_{2}^{2}; y, z \ge 0$ | VectorOfVariables | RotatedSecondOrderCone | ๐ |
| $\left( \vec{a}'_1 \vec{x} + b_1,\vec{a}'_2 \vec{x} + b_2,\vec{a}'_3 \vec{x} + b_3 \right) \in E$ | VectorAffineFunction | ExponentialCone | โ |
| $A(\vec{x}) \in S_{+}$ | VectorAffineFunction | PositiveSemidefiniteConeTriangle | โ |
| $B(\vec{x}) \in S_{+}$ | VectorAffineFunction | PositiveSemidefiniteConeSquare | โ |
| $\vec{x} \in S_{+}$ | VectorOfVariables | PositiveSemidefiniteConeTriangle | โ |
| $\vec{x} \in S_{+}$ | VectorOfVariables | PositiveSemidefiniteConeSquare | โ |### Quadratic constraints
| Mathematical Constraint | MOI Function | MOI Set | Status |
| ----------------------------------------------------- | ----------------------- | ------------------------ | :----: |
| $\vec{x} Q \vec{x} + \vec{a}' \vec{x} + b \ge 0$ | ScalarQuadraticFunction | GreaterThan | โป๏ธ |
| $\vec{x} Q \vec{x} + \vec{a}' \vec{x} + b \le 0$ | ScalarQuadraticFunction | LessThan | โ๏ธ |
| $\vec{x} Q \vec{x} + \vec{a}' \vec{x} + b = 0$ | ScalarQuadraticFunction | EqualTo | โ๏ธ |
| Bilinear matrix inequality | VectorQuadraticFunction | PositiveSemidefiniteCone | โ |### Discrete and logical constraints
| Mathematical Constraint | MOI Function | MOI Set | Status |
| ------------------------------------------------------------------------------------ | -------------------- | -------------- | :----: |
| $x_i \in \mathbb{Z}$ | VariableIndex | Integer | โ๏ธ |
| $x_i \in \left\lbrace{0, 1}\right\rbrace$ | VariableIndex | ZeroOne | โ๏ธ |
| $x_i \in \left\lbrace{0}\right\rbrace \cup \left[{l, u}\right]$ | VariableIndex | Semicontinuous | โ |
| $x_i \in \left\lbrace{0}\right\rbrace \cup \left[{l, l + 1, \dots, u - 1, u}\right]$ | VariableIndex | Semiinteger | โ |
| [ยน](#1) | VectorOfVariables | SOS1 | โ๏ธ |
| [ยฒ](#2) | VectorOfVariables | SOS2 | ๐ |
| $y = 1 \implies \vec{a}' \vec{x} \in S$ | VectorAffineFunction | Indicator | ๐ |//////ยน
At most one component of **x** can be nonzeroยฒ
At most two components of **x** can be nonzero, and if so they must be adjacent components| Symbol | Meaning |
| :----: | ---------------------------------- |
| โ๏ธ | Available |
| โป๏ธ | Available through Bridges[ยณ](#3) |
| โ | Unavailable |
| โ | Under Development (Available soon) |
| ๐ | Under Research |ยณ
[MOI Bridges](https://jump.dev/MathOptInterface.jl/stable/submodules/Bridges/reference/) provide equivalent constraint mapping.โด
If you think this list is incomplete, consider creating an [Issue](https://github.com/psrenergy/ToQUBO.jl/issues) or opening a [Pull Request](https://github.com/psrenergy/ToQUBO.jl/pulls).## Citing ToQUBO.jl
If you use `ToQUBO.jl` in your work, we kindly ask you to include the following citation:
```tex
@software{toqubo:2023,
author = {Pedro Maciel Xavier and Pedro Ripper and Tiago Andrade and Joaquim Dias Garcia and David E. Bernal Neira},
title = {{ToQUBO.jl}},
month = {feb},
year = {2023},
publisher = {Zenodo},
version = {v0.1.5},
doi = {10.5281/zenodo.7644291},
url = {https://doi.org/10.5281/zenodo.7644291}
}
```---