skills/tabular/simulated-annealing-multi-operator/SKILL.md
Simulated annealing with diverse move operators (translate, rotate, swap, Levy flight, squeeze) and adaptive reheating on stagnation for combinatorial optimization
npx skillsauth add wenmin-wu/ds-skills tabular-simulated-annealing-multi-operatorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Standard simulated annealing with a single perturbation type gets stuck in local optima. Using 10+ move operators — Gaussian translation, rotation, pair swaps, Levy flights, center-directed moves, boundary-focused moves — each randomly selected per step, explores the solution space more effectively. Combined with exponential cooling and adaptive reheating when improvement stalls, this handles diverse combinatorial optimization problems.
import math, random
def sa_optimize(state, score_fn, operators, T0=3.0, Tmin=1e-6,
alpha=0.9999, reheat_after=200):
best = state.copy()
best_score = cur_score = score_fn(state)
T = T0
no_improve = 0
for step in range(1_000_000):
op = random.choice(operators)
candidate = op(state, T / T0)
new_score = score_fn(candidate)
delta = new_score - cur_score
if delta < 0 or random.random() < math.exp(-delta / T):
state = candidate
cur_score = new_score
if new_score < best_score:
best = state.copy()
best_score = new_score
no_improve = 0
else:
no_improve += 1
else:
no_improve += 1
T *= alpha
if T < Tmin:
T = Tmin
if no_improve > reheat_after:
T = min(T * 5, T0 * 0.7)
no_improve = 0
return best, best_score
T/T0 for temperature-aware step sizesT * 5data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF