Skip to content

Commit 367cba8

Browse files
authored
First release of the framework (#1)
1 parent be8e686 commit 367cba8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+14733
-1526
lines changed

.flake8

-18
This file was deleted.

.github/codecov.yml

-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,3 @@ coverage:
1111
patch:
1212
default:
1313
threshold: 1%
14-
codecov:
15-
notify:
16-
after_n_builds: 8

.github/dependabot.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
groups:
6+
github-actions:
7+
patterns:
8+
- "*"
9+
schedule:
10+
interval: "weekly"
11+
day: "wednesday"
12+
time: "06:00"
13+
timezone: "Europe/Vienna"
14+
15+
- package-ecosystem: "pip"
16+
directory: "/"
17+
groups:
18+
python-dependencies:
19+
patterns:
20+
- "*"
21+
schedule:
22+
interval: "weekly"
23+
day: "friday"
24+
time: "06:00"
25+
timezone: "Europe/Vienna"

.github/workflows/cd.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
python-packaging:
99
name: 🐍 Packaging
10-
uses: cda-tum/mqt-workflows/.github/workflows/[email protected].0
10+
uses: cda-tum/mqt-workflows/.github/workflows/[email protected].1
1111
with:
1212
pure-python: true
1313

.github/workflows/ci.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,19 @@ concurrency:
1414
jobs:
1515
change-detection:
1616
name: 🔍 Change
17-
uses: cda-tum/mqt-workflows/.github/workflows/[email protected].0
17+
uses: cda-tum/mqt-workflows/.github/workflows/[email protected].1
1818

1919
python-tests:
2020
name: 🐍 Test
2121
needs: change-detection
2222
if: fromJSON(needs.change-detection.outputs.run-python-tests)
23-
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
24-
secrets:
25-
token: ${{ secrets.CODECOV_TOKEN }}
23+
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
2624

2725
code-ql:
2826
name: 📝 CodeQL
2927
needs: change-detection
3028
if: fromJSON(needs.change-detection.outputs.run-code-ql)
31-
uses: cda-tum/mqt-workflows/.github/workflows/[email protected].0
29+
uses: cda-tum/mqt-workflows/.github/workflows/[email protected].1
3230

3331
required-checks-pass: # This job does nothing and is only used for branch protection
3432
name: 🚦 Check

.github/workflows/mypy.yml

-25
This file was deleted.

.pre-commit-config.yaml

+42-49
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,35 @@ ci:
1515
repos:
1616
# Standard hooks
1717
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: "v4.5.0"
18+
rev: v4.6.0
1919
hooks:
2020
- id: check-added-large-files
2121
- id: check-case-conflict
2222
- id: check-docstring-first
2323
- id: check-merge-conflict
24+
- id: check-symlinks
2425
- id: check-toml
2526
- id: check-yaml
2627
- id: debug-statements
2728
- id: end-of-file-fixer
2829
- id: mixed-line-ending
30+
- id: requirements-txt-fixer
2931
- id: trailing-whitespace
3032

33+
# Clean jupyter notebooks
34+
- repo: https://github.com/srstevenson/nb-clean
35+
rev: 3.2.0
36+
hooks:
37+
- id: nb-clean
38+
args:
39+
- --remove-empty-cells
40+
- --preserve-cell-metadata
41+
- raw_mimetype
42+
- --
43+
3144
# Handling unwanted unicode characters
3245
- repo: https://github.com/sirosen/texthooks
33-
rev: "0.6.2"
46+
rev: 0.6.6
3447
hooks:
3548
- id: fix-ligatures
3649
- id: fix-smartquotes
@@ -43,67 +56,47 @@ repos:
4356
- id: rst-directive-colons
4457
- id: rst-inline-touching-normal
4558

46-
# Clean jupyter notebooks
47-
- repo: https://github.com/srstevenson/nb-clean
48-
rev: "3.1.0"
49-
hooks:
50-
- id: nb-clean
51-
# Check for spelling
52-
- repo: https://github.com/codespell-project/codespell
53-
rev: "v2.2.6"
54-
hooks:
55-
- id: codespell
56-
args: ["-L", "wille,linz,fro"]
57-
exclude: "mqt/benchviewer/templates/legal.html"
58-
59-
# Format configuration files with prettier
60-
- repo: https://github.com/pre-commit/mirrors-prettier
61-
rev: "v3.0.3"
62-
hooks:
63-
- id: prettier
64-
types_or: [yaml, markdown, html, css, javascript, json]
65-
59+
# Python linting using ruff
6660
- repo: https://github.com/astral-sh/ruff-pre-commit
67-
rev: v0.1.4
61+
rev: v0.4.7
6862
hooks:
6963
- id: ruff
7064
args: ["--fix", "--show-fixes"]
7165
types_or: [python, pyi, jupyter]
7266
- id: ruff-format
7367
types_or: [python, pyi, jupyter]
7468

69+
# Static type checking using mypy
70+
- repo: https://github.com/pre-commit/mirrors-mypy
71+
rev: v1.10.0
72+
hooks:
73+
- id: mypy
74+
files: ^(src/mqt|tests)
75+
args: []
76+
additional_dependencies:
77+
- pytest
78+
- numpy
79+
7580
# Also run Black on examples in the documentation
7681
- repo: https://github.com/adamchainz/blacken-docs
7782
rev: 1.16.0
7883
hooks:
7984
- id: blacken-docs
80-
additional_dependencies: [black==23.*]
85+
additional_dependencies: [black==24.*]
8186

82-
- repo: https://github.com/pre-commit/mirrors-mypy
83-
rev: v1.6.1
87+
# Format configuration files with prettier
88+
- repo: https://github.com/pre-commit/mirrors-prettier
89+
rev: v4.0.0-alpha.8
8490
hooks:
85-
- id: mypy
86-
files: ^(src|tests)
87-
args: []
88-
additional_dependencies:
89-
- importlib_resources
90-
- qubovert
91-
- pytest==7.4.0
92-
- types-setuptools
93-
- setuptools<=65.6.3
94-
- sympy==1.12
95-
- numpy==1.23.5
96-
- dwave-samplers
97-
- dwave.system
98-
- docplex==2.25.236
99-
- qiskit==0.45.3
100-
- qiskit_optimization==0.4.0
101-
- qiskit-algorithms==0.2.1
102-
- qiskit_ibm_runtime==0.14.0
103-
- matplotlib
104-
- pandas
105-
- PyPortfolioOpt
106-
- scikit-learn
91+
- id: prettier
92+
types_or: [yaml, markdown, html, css, scss, javascript, json]
93+
94+
# Check for spelling
95+
- repo: https://github.com/codespell-project/codespell
96+
rev: v2.3.0
97+
hooks:
98+
- id: codespell
99+
args: ["-L", "wille,linz", "--skip", "*.ipynb"]
107100

108101
# Catch common capitalization mistakes
109102
- repo: local
@@ -112,7 +105,7 @@ repos:
112105
name: Disallow improper capitalization
113106
language: pygrep
114107
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest|Mqt|Tum
115-
exclude: (.joblib|.pre-commit-config.yaml)
108+
exclude: .pre-commit-config.yaml
116109

117110
# Check best practices for scientific Python code
118111
- repo: https://github.com/scientific-python/cookie

.readthedocs.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 2
2+
3+
submodules:
4+
include: all
5+
recursive: true
6+
7+
build:
8+
os: ubuntu-22.04
9+
tools:
10+
python: "3.11"
11+
jobs:
12+
post_checkout:
13+
# Skip docs build if the commit message contains "skip ci"
14+
- (git --no-pager log --pretty="tformat:%s -- %b" -1 | grep -viq "skip ci") || exit 183
15+
# Skip docs build if there are no changes related to docs
16+
- |
17+
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- docs/ .readthedocs.yaml src/mqt/ .github/contributing* .github/support*;
18+
then
19+
exit 183;
20+
fi
21+
22+
sphinx:
23+
configuration: docs/conf.py
24+
25+
python:
26+
install:
27+
- method: pip
28+
path: .
29+
extra_requirements:
30+
- docs

CITATION.bib

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
@MISC{volpe2024towards,
1+
@INPROCEEDINGS{volpe2024towards,
22
AUTHOR = {D.Volpe and N. Quetschlich and M. Graziano and G. Turvani and R. Wille},
33
TITLE = {{Towards an Automatic Framework for Solving Optimization Problems with Quantum Computers}},
44
YEAR = {2024},
5-
EPRINT = {},
6-
EPRINTTYPE = {},
5+
BOOKTITLE = {IEEE International Conference on Quantum Software (QSW)},
76
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# MQT Quantum Auto Optimizer: Automatic Framework for Solving Optimization Problems with Quantum Computers
1919

20-
MQT Quantum Auto Optimizer is a framework that allows one to automatically translate an optimization problem into a quantum-compliant formulation and to solve it with one of the main quantum solvers (Quantum Annelar, QAOA, VQE and GAS)
20+
MQT Quantum Auto Optimizer is a framework that allows one to automatically translate an optimization problem into a quantum-compliant formulation and to solve it with one of the main quantum solvers (Quantum Annealer, Quantum Approximate Optimization Algorithm, Variational Quantum Eigensolver and Grover Adaptive Search)
2121

2222
MQT Quantum Auto Optimizer is part of the [Munich Quantum Toolkit (MQT)](https://mqt.readthedocs.io/) developed by the [Chair for Design Automation](https://www.cda.cit.tum.de/) at the [Technical University of Munich](https://www.tum.de/). This framework has been developed in collaboration with the [VLSI Lab](https://www.vlsilab.polito.it/) of [Politecnico di Torino](https://www.polito.it).
2323

docs/Constraints.rst

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Constraints Class
2+
=================
3+
4+
It manages the constraints of the problem. It is used to store the constraints and to check if a solution satisfies them.
5+
6+
Constraints types supported
7+
---------------------------
8+
9+
Types of constraints supported:
10+
11+
- *Equality*, writing the equality as a quadratic penalty function, i.e. sum = b imposed with g = (sum-b)^2
12+
- *Inequality*, moving to equality with the continuous auxiliary variables a to be expanded with the encoding technique of the Variables class
13+
- *Not constraint* among binary variables, i.e. Not(a) = b imposed with g = 2ab - a - b + 1
14+
- *And constraint* among binary variables, i.e. a and b = c imposed with ab -2(a+b)c + 3c
15+
- *Or constraint* among binary variables, i.e. a or b = c imposed with ab + (a+b)(1-2c) + c
16+
- *Xor constraint* among binary variables, i.e. a xor b = c imposed with 2ab - 2(a+b)c - 4(a+b)\_aux+4_aux c +a+b+c+4+\_aux
17+
18+
Constraints declarations
19+
------------------------
20+
21+
The class provides methods to declare variables:
22+
23+
- *add_constraint(expression: str, hard: bool = True, variable_precision: bool = True)*: adds a constraint to the list of constraints.
24+
- *expression* is a string that represents the constraint
25+
- *hard* parameter is a boolean that indicates if the constraint is hard or soft.
26+
- *variable_precision* parameter is a boolean that indicates if the constraint is to be considered in the precision of the variables.
27+
28+
Example:
29+
--------
30+
31+
.. code-block:: python
32+
33+
from mqt.qao.constraints import Constraints
34+
from mqt.qao.variables import Variables
35+
36+
constraint = Constraints()
37+
variables = Variables()
38+
variables.add_binary_variable("a")
39+
variables.add_binary_variable("b")
40+
variables.add_binary_variable("c")
41+
variables.add_discrete_variable("d", [-1, 1, 3])
42+
variables.add_continuous_variable("e", -2, 2, 0.25, "", "")
43+
constraint.add_constraint("~a = b", True, True, False)
44+
constraint.add_constraint("a | b = c", True, True, False)
45+
constraint.add_constraint("d + e <= 1", True, True, False)

docs/Contributing.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. include:: ../.github/contributing.rst

0 commit comments

Comments
 (0)