Skip to main content

Simulacao de caminhadas quanticas discretas em grafos toroidais n-dimensionais

Project description

biblioteca-qw

PyPI version 3.4 Python License: MIT Tests

Biblioteca Python para simulação de caminhadas quânticas discretas (DTQW) em grafos toroidais n-dimensionais, com suporte a vértices marcados (oráculo de Grover), persistência de resultados via JSON Server e exportação CSV/JSON.


Instalação

pip install biblioteca-qw

Com dependências de visualização

pip install "biblioteca-qw[viz]"

Instalação para desenvolvimento

git clone https://github.com/Igoro2016/biblioteca_qw.git
cd biblioteca_qw
pip install -e ".[dev]"

Uso rápido

from biblioteca_qw import QuantumWalkSimulation, to_csv, print_summary

# Configurar a simulação
sim = QuantumWalkSimulation(
    L=3,                     # 3 vértices por dimensão
    n=2,                     # grafo toroidal 2D (3x3 = 9 vértices)
    num_selfloop=1,          # 1 self-loop por vértice
    t_f=3500,                # 3500 passos de simulação
    weight_value=1.0,        # peso das arestas
    marked_vertices=[0, 1]  # vértices marcados (oráculo)
)

# Executar
probs, det_times = sim.run()

# Exportar resultados
to_csv(probs, det_times, "probs.csv", "det_times.csv")

# Resumo
print_summary(probs, det_times)

Com persistência REST (JSON Server)

# Instale e inicie o JSON Server
npm install -g json-server
json-server --watch db.json
sim = QuantumWalkSimulation(
    L=3, n=2, num_selfloop=1, t_f=100,
    weight_value=1.0, marked_vertices=[0],
    db_url="http://localhost:3000"   # habilita persistência REST
)
probs, det_times = sim.run()

Parâmetros

Parâmetro Tipo Descrição
L int Vértices por dimensão (≥ 2)
n int Número de dimensões (≥ 1)
num_selfloop int Self-loops por vértice (≥ 0)
t_f int Passos de simulação (≥ 1)
weight_value float Peso das arestas
marked_vertices list[int] Índices dos vértices marcados
db_url str | None URL do JSON Server (opcional)

Resultados

Array Shape Descrição
probs (t_f, N) Probabilidade por vértice em cada passo
det_times (t_f,) Probabilidade de detecção acumulada nos marcados

API

from biblioteca_qw import (
    QuantumWalkSimulation,   # simulador principal
    adjacency_matrix,        # matriz de adjacência do grafo toroidal
    degree,                  # grau dos vértices
    spectral_gap,            # gap espectral do laplaciano
    summary,                 # estatísticas dos resultados
    to_csv, to_json,         # exportação
    load_csv,                # carregamento
    print_summary,           # impressão formatada
)

Modelo matemático

A biblioteca implementa caminhadas quânticas discretas no espaço de Hilbert:

H = H_P ⊗ H_C

onde H_P é o espaço de posição (dim = L^n) e H_C é o espaço de moeda (dim = 2n + num_selfloop).

O operador de evolução é U = S · C_oracle, onde:

  • S: operador de deslocamento condicional
  • C_oracle: moeda de Grover nos vértices normais; moeda oráculo (−I) nos marcados

Testes

pytest tests/ -v
pytest tests/ --cov=biblioteca_qw --cov-report=term-missing

Licença

MIT © Igor (2025)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

biblioteca_qw-3.4.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

biblioteca_qw-3.4-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file biblioteca_qw-3.4.tar.gz.

File metadata

  • Download URL: biblioteca_qw-3.4.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for biblioteca_qw-3.4.tar.gz
Algorithm Hash digest
SHA256 8534ef85d998260be6bc5c31fab8d355481b670b42213d1fcedc3de2455838bd
MD5 cf60d53be58051cc8c5c09fb25b746e8
BLAKE2b-256 09341063b10b364471d9c5a6acd8e0485fb2b75b8f1e0113ba33b793f6118ce8

See more details on using hashes here.

File details

Details for the file biblioteca_qw-3.4-py3-none-any.whl.

File metadata

  • Download URL: biblioteca_qw-3.4-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for biblioteca_qw-3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 56ad73de622a32c9b6052483cd27cac8e7c98921eb3513b6b33b0c11ccd41948
MD5 e4d7c4f3ca9f30922327124bd4429a4f
BLAKE2b-256 78f69f784d232d6b1c6d7e19c06b3795da36f8748fa666e9ee49282f2aa66d1e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page