GithubHelp home page GithubHelp logo

dyln / hillclimb-sudokusolver Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sheaney/hillclimb-sudokusolver

0.0 2.0 0.0 172 KB

Tries to solve a 9x9 Sudoku using local search hill climb

Scala 100.00%

hillclimb-sudokusolver's Introduction

Sudoku Solver

This is a Scala implementation of a Sudoku solver for a 9x9 puzzle that uses a local search Hill Climb to find a solution. It will choose a better fitness cost with a probability of .995

Objective function: Number of repeated numbers in all the rows plus number of repeated numbers in each quadrant. All columns get initialized to already satisfy the property of containing numbers 1 through 9.

Transformation function: Implemented by doing a swap of numbers in the same column yet in distinct rows. A random column number is picked, then two random rows are selected with the only requirement that they must be different.

Stopping Criteria: If the number of iterations exceeds 5 million then the Hill Climb will terminate even though a solution may not have been found on the given input for the problem.

Requirements

java 1.6 or higher

sbt 0.12.2

Building

Change into main directory and run:

  1. sbt reload update
  2. sbt compile
  3. sbt run <filename> where <filename> is any custom file in the repository. Look at *.in files for examples on the format

Testing

Run tests from main directory:

sbt test

Benchmarks

Below are some benchmarks on the number of total iterations to 
convergence by varying the probability of choosing a 'worse' move 
for easy inputs (easy*.in) and hard inputs (difficult*.in)
  
Convergence

Easy Input
.001  => 1,608,918 ; 
.005  => 647,143 ; 211,313 ; 126,902 ; 434,617 ; 335,546 ; 627,381
.006  => 1,338,593
.0003 => 399,604 ; 5,131,079 ; nc (Over 5 min) 
.0004 => 54,692 ; 2,340,466
.0005 => 1,078,154
.0006 => 2,088,491

Difficult Input
.01   => nc (Over 10 min) ; nc (Over 10 min)
.001  => 70,373 ; nc
.003  => 1,342,784
.004  => 2,318,363
.005  => 797,134 ; 1,025,887 ; 3,394,429 ; 2,826,606
.0006 => 193,541
.0008 => 1,722,199

* nc - no convergence

hillclimb-sudokusolver's People

Contributors

sheaney avatar

Watchers

James Cloos avatar caner eren avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.