Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

TESA — Tunneling-Enhanced Simulated Annealing

A quantum collapse-inspired classical optimizer. Single file, NumPy only.

from TESA import TESA

best_spins, best_energy = TESA.optimize(energy_fn, delta_fn, n_spins=50)

How It Works

Quantum annealing uses an exponentially decaying tunneling strength to transition from exploration to exploitation. TESA translates this into a classical multi-restart strategy:

Quantum TESA
Γ(t) = G₀·(Gf/G₀)^t K restarts, T₀ₖ = G₀·(Gf/G₀)^{k/K}
High Γ → global exploration High T₀ → accept many uphill moves
Low Γ → local exploitation Low T₀ → mostly downhill moves

Each restart anneals from its own initial temperature. The first restart explores broadly; the last exploits deeply. This is the only element taken from quantum mechanics — no quantum hardware, no parallelism, just the exponential schedule.

Algorithm

for restart k in 0..K-1:
    T0 = G0 * (Gf/G0)^(k/K)         # decreasing initial temperatures
    s = random spins
    for step t in 0..steps_per_restart:
        temp = T0 * (1 - t/steps)^2  # intra-round cooling
        i = random spin
        dE = energy_change(flip i)
        if dE < 0 or random() < exp(-dE/temp):
            flip i
    local_search(s)                  # refine to local optimum
    keep_best(s)

Per-step cost is identical to standard simulated annealing: one spin flip evaluated. Same budget, better schedule.

Usage

from TESA import TESA

# Any Ising spin problem: define energy and flip delta
def energy(spins):           # spins: numpy array of +/-1
    ...
def delta(spins, i):         # energy change from flipping spin i
    ...

best_spins, best_E = TESA.optimize(
    energy, delta,
    n_spins=100,              # number of binary variables
    K=10,                     # restarts (default: 10)
    G0=5.0,                   # first restart temp (default: 5.0)
    Gf=0.005,                 # last restart temp (default: 0.005)
)

# Built-in: MAX-CUT
from TESA import TESA, random_graph
adj = random_graph(n=100, density=0.3)
cut, group_A, group_B = TESA.solve_maxcut(adj)

Parameters

Parameter Default Role
K 10 Number of restarts
G0 5.0 Initial temperature (first restart)
Gf 0.005 Initial temperature (last restart)
T n × 50 Total spin flips

License

MIT

About

Quantum collapse-inspired classical optimizer. +2–16% over SA with equal budget. Single file, NumPy only.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages