Metadata-Version: 2.4
Name: mle_decoder
Version: 0.2.0
Summary: Most-likely error (MLE) decoder that uses gurobi to solve the mixed-interger (linear) programming problem
Author-email: Marc Serra Peralta <marcserraperalta@gmail.com>
Maintainer-email: Marc Serra Peralta <marcserraperalta@gmail.com>
License: MIT License
        
        Copyright (c) 2025 MarcSerraPeralta
        
        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.
        
Keywords: MLE,decoder,quantum error correction,qec
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: stim
Requires-Dist: gurobipy
Requires-Dist: scipy
Provides-Extra: dev
Requires-Dist: pip-tools; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: pytest-black; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: flake8-print; extra == "dev"
Requires-Dist: pytest-flake8; extra == "dev"
Requires-Dist: gprof2dot; extra == "dev"
Dynamic: license-file

# mle-decoder

![example workflow](https://github.com/MarcSerraPeralta/mle-decoder/actions/workflows/ci_pipeline.yaml/badge.svg)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
![PyPI](https://img.shields.io/pypi/v/mle-decoder?label=pypi%20package)

Most-likely error (MLE) decoder that uses gurobi to solve the mixed-interger (linear) programming problem.

The decoding hypergraph is specified using `stim.DetectorErrorModel`.


## MLE optimization description

The problem of finding the most likely error can be mapped to a mixed-integer (linear) programming (MILP) problem. 
This can be solved by optimization solvers like Gurobi. The mapping to a MILP problem is _(source: https://arxiv.org/abs/2403.03272)_

![alt text](https://github.com/MarcSerraPeralta/mle-decoder/blob/main/images/mle_description.png?raw=true)

Note that $C_i \in \\{-1, +1\\}$. 


## Setting up the gurobi license

1. Create a free academic account
2. Request a license, which will give you a license key
3. Install the Gurobi Optimizer (or install `gurobipy` through conda) so that we can run the `grbgetkey` command
4. Run `grbgetkey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` using your license number
5. At the end of `~/.bashrc` add `export GRB_LICENSE_FILE=/path/to/license.lic` where the license path is printed when running the previous step
6. Run `source ~/.bashrc` or open a new terminal and check that the license installation is successful by running the `gurobi.sh` command
