Giter Club home page Giter Club logo

quantum-portfolio-optimization's Introduction

Portfolio Optimization on a Quantum computer

Qiskit implementation of a Portfolio Optimization.

Requirements

  • Python 3.8+
  • Qiskit
  • CVXPY
  • MOSEK
  • tqdm
pip install -r requirements.txt

VQE Solver

The VQE Solver takes a Covariance matrix and changes it to an Ising problem. The Ising model's hamiltonian is then minimized with the VQE.

from src.solver.vqe.vqe_solver import VQESolver

from qiskit import BasicAer
from qiskit.utils import QuantumInstance
from qiskit.circuit.library import TwoLocal
from qiskit.algorithms.optimizers import SLSQP

vqe = VQESolver()
vqe.qp(Cov = Cov)
vqe.to_ising(Nq = Nq)

# Prepare QuantumInstance
qi = QuantumInstance(BasicAer.get_backend('statevector_simulator'), seed_transpiler=seed, seed_simulator=seed)

# Select the VQE parameters
N = Cov.shape[0]
ansatz = TwoLocal(num_qubits=N*Nq, 
                    rotation_blocks=['ry','rz'], 
                    entanglement_blocks='cz',
                    reps=args.reps,
                    entanglement='full')
slsqp = SLSQP(maxiter=args.maxiter)
vqe.vqe_instance(ansatz=ansatz, optimizer=slsqp, quantum_instance=qi)

res_vqe = vqe.solve()
print(res_vqe)

License

Apache License 2.0

quantum-portfolio-optimization's People

Contributors

adelshb avatar

Stargazers

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