Simulated Annealing

Step-by-Step N-Queens Execution with Acceptance Probability

Watch how temperature controls the acceptance of worse moves!

Simulated Annealing Strategy

🎯 Goal:

Place 5 queens with no conflicts (E = 0)

🔥 Key Idea:

Accept bad moves with decreasing probability

Innovation: Unlike hill climbing, simulated annealing can escape local maxima by accepting worse moves when temperature is high, gradually becoming more selective as it cools.
Acceptance Probability
P = eΔE/T
ΔE = Energy change
T = Temperature
P = Acceptance probability

Step 1: Initial Configuration

Current board state
8
Current Energy (conflicts)
100.0
Temperature
1
Step Number
0
Moves Accepted
0
Moves Rejected
🌡️ Temperature Schedule
Cold (0°) Hot (100°)

Algorithm Controls

°
Range: 1-500°. Higher = more exploration.
×
Range: 0.8-0.99. Lower = faster cooling.
Set initial temperature and click "Next Step" to see the first move attempt and acceptance probability calculation.

Algorithm Execution

🚀 Starting Configuration

Initial random placement of 5 queens on the board. Current conflicts: 8

Temperature starts at maximum value for exploration.

Move Analysis

Move analysis will appear here when you click "Next Step"

Key Learning Points

🔥 High Temperature (Early)
  • Accept most moves (good and bad)
  • High exploration
  • Can escape local optima
  • P ≈ 1 when T is large
❄️ Low Temperature (Late)
  • Accept only better moves
  • Exploitation mode
  • Behaves like hill climbing
  • P ≈ 0 when T approaches 0
✅ Improving Moves (ΔE > 0)

Always accepted regardless of temperature.
P = e(+ΔE)/T > 1, so we accept with probability 1.

⚠️ Worsening Moves (ΔE < 0)

Accepted with probability P = eΔE/T
Higher temperature = more likely to accept bad moves.