Skip to content

bergio13/simulated-annealing-sudoku

Repository files navigation

Simulated Annealing Applied to Sudoku Puzzles

Sudoku Solution GIF

This project implements a Simulated Annealing (SA) algorithm to solve Sudoku puzzles, inspired by the paper "Metaheuristics can solve Sudoku puzzles" by Lewis (2007). The algorithm demonstrates a reliable approach to consistently find solutions to Sudoku puzzles using a metaheuristic optimization technique.

Project Overview

The SA algorithm works by iteratively exploring the solution space and probabilistically allowing worse solutions to escape local minima. As the process progresses, the "temperature" parameter gradually decreases, refining the search. If a better solution isn't found within a set number of steps, a reheating mechanism is applied to help the search escape potential plateaus.

Sudoku Board Example

File Descriptions

  • notebook.ipynb - A Jupyter Notebook demonstrating and visualizing the SA approach for solving Sudoku puzzles, with step-by-step explanations.
  • simulated_annealing.py - Core implementation of the Simulated Annealing algorithm.
  • sudoku_solver.py - Contains helper functions, the objective funciton, the nieghborhood operator, the delta evaluation function and the necessary Sudoku-specific logic required by the SA algorithm.

Key Functions

Visualization and Results

The results and visualizations can be found in the notebook.ipynb file. Open it with Jupyter Notebook to see step-by-step explanations and plots.


Reference

About

Solving sudoku using simulated annealing optimization

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published