GithubHelp home page GithubHelp logo

davidedellagiustina / qasp-solver Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 153 KB

Quantum algorithms for solving ASP programs. MSc thesis project.

License: MIT License

Python 98.50% Just 1.50%
amplitude-amplification amplitude-estimation answer-set-programming qiskit quantum-algorithms quantum-computing

qasp-solver's Introduction

Table of Contents โ†—๏ธ

Logo

QASP Solver

ASP python qiskit MIT license
Quantum algorithms for solving ASP programs.

Build instructions

Python virtual environment

I strongly recommend using a Python virtual environment to install all the required dependencies, in order to avoid (possibly) messing with other Python projects you may be working with.

A new venv can be created by running the following command:

python -m venv ./.py-venv --prompt qasp-solver

To enter (and then quit) the environment, the following commands can be used from the directory where the venv folder was created:

source ./.py-venv/bin/activate # Enter the venv
deactivate # Quit the venv

The rest of this section assumes that you run all the provided commands while inside the virtual environment.

Dependencies

First of all, install the Python dependencies specified in the requirements.txt file:

pip install -r ./requirements.txt

At the time of writing, the version of the tweedledum library packaged by PyPI is broken, thus it cannot be installed with pip. Instead, use the following commands to download, build, and install it from the publicly available sources:

# Install build dependencies (Ubuntu)
sudo apt install -y wget gcc g++ cmake ninja-build

# Setup build folder
WORKDIR=`pwd`
mkdir build && cd ./build
mkdir lib-tweedledum && cd ./lib-tweedledum

# Download and unpack sources
wget https://files.pythonhosted.org/packages/source/t/tweedledum/tweedledum-1.1.1.tar.gz \
    https://github.com/boschmitt/tweedledum/pull/170.patch \
    https://github.com/pybind/pybind11/archive/refs/tags/v2.10.4.tar.gz
tar xvf tweedledum-1.1.1.tar.gz && tar xvf v2.10.4.tar.gz
cd ./tweedledum-1.1.1

# Patch sources
patch --forward --strip=1 --input="../170.patch"
cd ./external
rm -r pybind11 && mv ../../pybind11-2.10.4 pybind11
cd ../include/tweedledum/IR
sed -i '6s/.*/#include <cstdint>/' ./Cbit.h
cd ../../..
sed -i 's/project/option/' ./pyproject.toml

# Install library
python ./setup.py build
pip install .

# Cleanup
cd ${WORKDIR} && unset WORKDIR

Optionally, you can check that the installation was successful by listing the installed libraries:

pip list | grep 'tweedledum'

Running the examples

Some examples that use QASP can be found in the ./src/examples folder of this repository.

In order to run them, first install the just command runner:

snap install --edge --classic just
just -l # Show available commands

To see a list of all the available examples, run:

just list

Then, to run one, use the following command:

just run <name>

qasp-solver's People

Contributors

davidedellagiustina avatar

Watchers

 avatar

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.