Code Monkey home page Code Monkey logo

qumcmc's Introduction

quMCMC

This repository contains the python implementation of Quantum Enhanced Markov Chain Monte Carlo. The code is based mainly on the algorithm reported by David Layden et al. in Quantum-enhanced Markov chain Monte Carlo. The code provides support for reproducing most of the results discussed in the original paper, and the adavantages of the Quantum Enhanced MCMC (quMCMC) over classical MCMC has been highlighted.

Installation

The package can be installed using pip in the main directory of the package as,

>>> pip install .

Example Usage

## DEFINE MODEL
n_spins = 10

## construct problem Hamiltonian ##
shape_of_J=(n_spins,n_spins)

## defining J matrix (mutual 1-1 interaction)
J =  np.random.uniform(low= -2, high= 2, size= shape_of_J )
J = 0.5 * (J + J.transpose() )

J = np.round( J - np.diag(np.diag(J)) , decimals= 3)

# defining h
h = np.round(0.5 * np.random.randn(n_spins), decimals=2)

# instantiate the model
model = IsingEnergyFunction(J, h, name= 'my_model')
=============================================
            MODEL : my_model
=============================================
Non-zero Interactions (J) : 45 / 45
Non-zero Bias (h) : 9 / 10
---------------------------------------------
Average Interaction Strength <|J|> :  0.5966799999999999
Average Bias Strength <|h|>:  0.5010000000000001
alpha :  0.5606804251097042
---------------------------------------------
## set current beta
beta = 1.100209

## RUN EXACT SAMPLING
exact_sampled_model = Exact_Sampling(model, beta)

steps = 10000
## RUN CLSSICAL SAMPLING
cl_chain =classical_mcmc(
    n_hops=steps,
    model=model,
    temperature=1/beta,
)
## RUN QUUANTUM SAMPLING
qamcmc_chain =quantum_enhanced_mcmc(
    n_hops=steps,
    model=model,
    temperature=1/beta,
)

For a more detailed example check the tutorial.ipynb

References

  1. Quantum-enhanced Markov chain Monte Carlo by David Layden et al.
  2. Qulacs Simulator
  3. Qiskit Aer Simulator

License

The package is licensed under MIT License

qumcmc's People

Contributors

pafloxy avatar neelkanthrawat avatar msrudolph avatar

Stargazers

Chanandellar Bong avatar Owais Ishtiaq Siddiqui avatar  avatar  avatar  avatar 老鸡奇遇记 avatar Sujay Srivastava avatar  avatar Shehbaz Tariq avatar  avatar Etendra Verma avatar  avatar  avatar  avatar

Watchers

Kostas Georgiou avatar  avatar  avatar  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.