Giter VIP home page Giter VIP logo

qubo.jl's Introduction

QUBO.jl

QUBO.jl

Code Coverage CI Docs Zenodo/DOI JuliaCon 2022 arXiv

A Julia ecosystem for Quadratic Unconstrained Binary Optimization

QUBO.jl is an all-in-one package for working with QUBO models in JuMP and interfacing with their solvers. This project aggregates and extends functionality from its complementary packages ToQUBO.jl, QUBODrivers.jl and QUBOTools.jl.

QUBO? 🟦

QUBO is an acronym for Quadratic Unconstrained Binary Optimization, a notorious family of Combinatorial Optimization problems. Recently, significant advances in computing systems and algorithms specialized for sampling QUBO solutions have contributed to its increasing popularity.

These novel tools 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, not to mention traditional methods such as Simulated Annealing and Parallel Tempering.

Mathematical Model

Conceptually speaking, it is an optimization model with a quadratic objective function on binary variables and no constraints. Despite being very simple, these models are capable of representing other nonconvex global optimization problems.

$$\begin{array}{rl} \min & \alpha \left[\mathbf{x}' \mathbf{Q}\,\mathbf{x} + \mathbf{\ell}' \mathbf{x} + \beta \right] \\\ \textrm{s.t.} & \mathbf{x} \in \lbrace{0, 1}\rbrace^{n} \end{array}$$
Show Description

Analizing the model attentively, let $\mathbf{x}$ be a vector of boolean (zero-one) variables. Take also the vector of linear terms $\mathbf{\ell} \in \mathbb{R}^{n}$ and the strictly upper triangular matrix of quadratic terms $\mathbf{Q} \in \mathbb{R}^{n \times n}$. Last but not least, consider $\alpha, \beta \in \mathbb{R}$ as the scaling and offset parameters, respectively.

Note that in this kind of problem, $\min$ and $\max$ are interchangeable under sign inversion. Also, spin variables $\mathbf{s} \in \lbrace{\pm 1}\rbrace^{n}$ may be employed instead, assuming that $s = 2x - 1$ by convention.

Quick Start πŸš€

Instalation

import Pkg

Pkg.add("QUBO")

Example

Given the following binary Knapsack Problem

$$\begin{array}{rl} \max & x_{1} + 2 x_{2} + 3 x_{3} \\\ \textrm{s.t.} & 0.3 x_{1} + 0.5 x_{2} + x_{3} \leq 1.6 \\\ & \mathbf{x} \in \mathbb{B}^{3} \end{array}$$

one could write a simple JuMP model and have its constraint automatically encoded by ToQUBO.jl.

Show Code
using JuMP
using QUBO

model = Model(() -> ToQUBO.Optimizer(ExactSampler.Optimizer))

@variable(model, x[1:3], Bin)
@objective(model, Max, x[1] + 2 * x[2] + 3 * x[3])
@constraint(model, 0.3 * x[1] + 0.5 * x[2] + x[3] <= 1.6)

optimize!(model)

for i = 1:result_count(model)
    xi = value.(x, result = i)
    yi = objective_value(model, result = i)

    println("x: ", xi, "; cost = ", yi)
end

Overview πŸ—ΊοΈ

ToQUBO.jl

ToQUBO.jl

ToQUBO.jl is a Julia package to reformulate general optimization problems into QUBO (Quadratic Unconstrained Binary Optimization) instances. This tool aims to convert a broad range of JuMP problems for straightforward application in many physics and physics-inspired solution methods whose normal optimization form is equivalent to the QUBO. Not only it is has the widest constraint coverage but also is the most performant QUBO reformulation tool available.

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. ToQUBO.jl was written as a MathOptInterface (MOI) layer that automatically maps between input and output models, thus providing a smooth JuMP modeling experience.

QUBODrivers.jl

QUBODrivers.jl

This package aims to provide a common MOI-compliant API for QUBO Sampling and Annealing machines. It also contains testing tools, including utility samplers for performance comparison and sanity checks.

It was designed to allow algorithm developers and hardware manufacturers to easily connect their products to the JuMP ecosystem. Its simple interface paves the path for the rapid integration of heterogeneous QUBO solvers, including cloud-based Quantum Computing services (DWave.jl, QiskitOpt.jl); Quantum Simulation software (QuantumAnnealingInterface.jl; CIMOptimizer.jl) and Heuristic solvers (MQLib.jl, DWaveNeal.jl).

QUBOTools.jl

QUBOTools.jl

The QUBOTools.jl package implements a broad set of utilities for working with QUBO instances. It defines the abstract interfaces for representing both QUBO models and their solutions. Besides that, its library contains reference implementations for the proposed interface, making it ready to power other applications.

One of its main purposes is to provide fast and reliable conversion mechanism between common file formats for storing such problems. With QUBOTools.jl it is possible to read models from various benchmarking databases and also write models in specifications that most devices will directly handle.

Citing QUBO.jl πŸ“‘

If you find QUBO.jl and its packages useful in your work, we kindly request that you cite the following paper (preprint):

@misc{qubojl:2023,
  title         = {QUBO.jl: A Julia Ecosystem for Quadratic Unconstrained Binary Optimization}, 
  author        = {Pedro {Maciel Xavier} and Pedro Ripper and Tiago Andrade and Joaquim {Dias Garcia} and Nelson Maculan and David E. {Bernal Neira}},
  year          = {2023},
  doi           = {10.48550/arXiv.2307.02577},
  eprint        = {2307.02577},
  archivePrefix = {arXiv},
  primaryClass  = {math.OC},
}

This project is part of a collaboration involving PSR Energy Consulting & Analytics, the Federal University of Rio de Janeiro (UFRJ), Purdue University and the Universities Space Research Association (USRA).

PSR; UFRJ; Purdue; USRA

qubo.jl's People

Contributors

pedromxavier avatar pedroripper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

secquoia

qubo.jl's Issues

Architecture discussion

From @bernalde's sketch of the architecture on the last dev call, I'm writing this issue with a mermaid flowchart.
This could be placed in the documentation afterwards.

---
title: General Architecture
---
%%{init: {'theme':'neutral'}}%%
flowchart LR;
    subgraph LEGEND ["Legend"]
        direction LR
      start1[ ] --->|"Model I/O"| stop1[ ]
      style start1 height:0px;
      style stop1 height:0px;
      start2[ ] -..->|"Data I/O"| stop2[ ]
      style start2 height:0px;
      style stop2 height:0px;    
    end


    MODEL["<div style='font-family: cursive'>opt f(x)<br>g(x) in S</div>"];
    OPTMODEL["<code>opt f(x)<br>g(x) in S</code>"];
    QUBOMODEL["<code>opt x' Q x<br>x in {0, 1}</code>"];

    subgraph QUBO ["QUBO.jl"]
        direction LR;
        TOQUBO(["ToQUBO.jl"]);
        QUBODRIVERS(["QUBODrivers.jl"]);
        QUBOTOOLS(["QUBOTools.jl"]);

        QUBOTOOLS <-.-> QUBODRIVERS;
        QUBOTOOLS <-.-> TOQUBO;
    end

    TOQUBO --> QUBOMODEL;

    subgraph SAMPLERS ["QUBODrivers.jl-powered Samplers"]
        direction LR;
        DWAVE(["DWave.jl"]);
        DWAVENEAL(["DWaveNeal.jl"]);
        QUANTUMANNEALINGINTERFACE(["QuantumAnnealingInterface.jl"]);
        SAMPLERSELSE(["..."]);
    end

        QUBODRIVERS <-.-> DWAVE;
        QUBODRIVERS <-.-> DWAVENEAL;
        QUBODRIVERS <-.-> QUANTUMANNEALINGINTERFACE;
        QUBODRIVERS <-.-> SAMPLERSELSE;
    
    subgraph MIQP ["MIQP Solvers"]
        direction LR
        GUROBI(["Gurobi"]);
        CPLEX(["CPLEX"]);
        BARON(["BARON"]);
        MIQPELSE(["..."]);
    end

        QUBOMODEL --> DWAVE;
        QUBOMODEL --> DWAVENEAL;
        QUBOMODEL --> QUANTUMANNEALINGINTERFACE;
        QUBOMODEL --> SAMPLERSELSE;

        QUBOMODEL --> GUROBI;
        QUBOMODEL --> CPLEX;
        QUBOMODEL --> BARON;
        QUBOMODEL --> MIQPELSE;
   
    subgraph JUMP ["JuMP"]
        direction LR
        MOI(["MOI"]);
    end

    MODEL --> MOI;
    MOI ---> OPTMODEL --> TOQUBO;
    MOI ---> QUBOMODEL;

Feel free to edit it.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Adding Constraints and Penalties at the same time.

Hello!

I'd like to know how can I add a constraint and set its penalty at the same time. Which is the best way of doing that? Can I do it in batches (adding many constraints and their respective penalties in a single command)?

I haven't found an answer in the documentation, sorry if I missed something.

Thanks

Improve README layout

The main idea is to replace the "QUBO.jl features" section with something like
image
and remove those package's logos from the bottom and include PSR & Purdue logos (UFRJ? NASA?), eventually with a brief explanation on the partnership.

What do you think? @bernalde @pedroripper @joaquimg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.