GithubHelp home page GithubHelp logo

zib-iol / bellpolytopes.jl Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 386 KB

This julia package addresses the membership problem for local polytopes: it constructs Bell inequalities and local models in multipartite Bell scenarios with binary outcomes.

License: MIT License

Julia 100.00%
bell-inequalities conditional-gradients frank-wolfe local-polytope local-models

bellpolytopes.jl's Introduction

BellPolytopes.jl

Dev Build Status

This package addresses the membership problem for local polytopes: it constructs Bell inequalities and local models in multipartite Bell scenarios with binary outcomes.

The original article for which it was written can be found here:

Improved local models and new Bell inequalities via Frank-Wolfe algorithms.

Installation

The most recent release is available via the julia package manager, e.g., with

using Pkg
Pkg.add("BellPolytopes")

or the main branch:

Pkg.add(url="https://github.com/ZIB-IOL/BellPolytopes.jl", rev="main")

Getting started

Let's say we want to characterise the nonlocality threshold obtained with the two-qubit maximally entangled state and measurements whose Bloch vectors form an icosahedron. Using BellPolytopes.jl, here is what the code looks like.

julia> using BellPolytopes, LinearAlgebra

julia> N = 2; # bipartite scenario

julia> rho = rho_GHZ(N) # two-qubit maximally entangled state
4×4 Matrix{Float64}:
 0.5  0.0  0.0  0.5
 0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0
 0.5  0.0  0.0  0.5

julia> measurements_vec = icosahedron_vec() # Bloch vectors forming an icosahedron
6×3 Matrix{Float64}:
 0.0        0.525731   0.850651
 0.0        0.525731  -0.850651
 0.525731   0.850651   0.0
 0.525731  -0.850651   0.0
 0.850651   0.0        0.525731
 0.850651   0.0       -0.525731

julia> _, lower_bound, upper_bound, local_model, bell_inequality, _ =
       nonlocality_threshold(measurements_vec, N; rho = rho);

julia> println([lower_bound, upper_bound])
[0.7784, 0.7784]

julia> p = correlation_tensor(measurements_vec, N; rho = rho)
6×6 Matrix{Float64}:
  0.447214  -1.0       -0.447214   0.447214   0.447214  -0.447214
 -1.0        0.447214  -0.447214   0.447214  -0.447214   0.447214
 -0.447214  -0.447214  -0.447214   1.0        0.447214   0.447214
  0.447214   0.447214   1.0       -0.447214   0.447214   0.447214
  0.447214  -0.447214   0.447214   0.447214   1.0        0.447214
 -0.447214   0.447214   0.447214   0.447214   0.447214   1.0

julia> final_iterate = sum(local_model.weights[i] * local_model.atoms[i] for i in 1:length(local_model));

julia> norm(final_iterate - lower_bound * p) < 1e-3 # checking local model
true

julia> local_bound(bell_inequality)[1] / dot(bell_inequality, p) # checking the Bell inequality
0.7783914488195466

Under the hood

The computation is based on an efficient variant of the Frank-Wolfe algorithm to iteratively find the local point closest to the input correlation tensor. See this recent review for an introduction to the method and the package FrankWolfe.jl for the implementation on which this package relies.

In a nutshell, each step gets closer to the objective point:

  • either by moving towards a good vertex of the local polytope,
  • or by astutely combining the vertices (or atoms) already found and stored in the active set.
julia> res = bell_frank_wolfe(p; v0=0.8, verbose=3, callback_interval=10^2, mode_last=-1);

Visibility: 0.8
 Symmetric: true
   #Inputs: 6
 Dimension: 21

Intervals
    Print: 100
   Renorm: 100
   Reduce: 10000
    Upper: 1000
Increment: 1000

   Iteration        Primal      Dual gap    Time (sec)       #It/sec    #Atoms       #LMO
         100    8.7570e-03    6.0089e-02    6.9701e-04    1.4347e+05        11         26
         200    5.9241e-03    5.4948e-02    9.4910e-04    2.1073e+05        16         33
         300    3.5594e-03    3.4747e-02    1.1942e-03    2.5122e+05        18         40
         400    1.9068e-03    3.4747e-02    1.3469e-03    2.9697e+05        16         42
         500    1.8093e-03    5.7632e-06    1.5409e-03    3.2448e+05        14         48

    Primal: 1.81e-03
  Dual gap: 2.60e-08
      Time: 1.63e-03
    It/sec: 3.28e+05
    #Atoms: 14

v_c  0.778392

Going further

More examples can be found in the corresponding folder of the package. They include the construction of a Bell inequality with a higher tolerance to noise as CHSH as well as multipartite instances.

bellpolytopes.jl's People

Contributors

github-actions[bot] avatar matbesancon avatar pokutta avatar sebastiendesignolle avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

ryko24

bellpolytopes.jl's Issues

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!

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.