On the Combination of Constraint Programming and Stochastic Search: The Sudoku Case

Similar documents
Techniques for Generating Sudoku Instances

SUDOKU X. Samples Document. by Andrew Stuart. Moderate

isudoku Computing Solutions to Sudoku Puzzles w/ 3 Algorithms by: Gavin Hillebrand Jamie Sparrow Jonathon Makepeace Matthew Harris

UN DOS TREZ Sudoku Competition. Puzzle Booklet for Preliminary Round. 19-Feb :45PM 75 minutes

SudokuSplashZone. Overview 3

Sudoku Solvers. A Different Approach. DD143X Degree Project in Computer Science, First Level CSC KTH. Supervisor: Michael Minock

Task Scheduling. A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering. May 2016 Task Scheduling Slide 1

A Retrievable Genetic Algorithm for Efficient Solving of Sudoku Puzzles Seyed Mehran Kazemi, Bahare Fatemi

Task Scheduling. A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering. May 2007 Task Scheduling Slide 1

Spring 06 Assignment 2: Constraint Satisfaction Problems

Spring 06 Assignment 2: Constraint Satisfaction Problems

Serbian round at Logic Masters India

Chapter 4 Heuristics & Local Search

An improved strategy for solving Sudoku by sparse optimization methods

Investigation of Algorithmic Solutions of Sudoku Puzzles

Cracking the Sudoku: A Deterministic Approach

ISudoku. Jonathon Makepeace Matthew Harris Jamie Sparrow Julian Hillebrand

Rating and Generating Sudoku Puzzles Based On Constraint Satisfaction Problems

GET OVERLAPPED! Author: Huang Yi. Forum thread:

Griddler Creator. Supervisor: Linda Brackenbury. Temitope Otudeko 04/05

Yet Another Organized Move towards Solving Sudoku Puzzle

1 Recursive Solvers. Computational Problem Solving Michael H. Goldwasser Saint Louis University Tuesday, 23 September 2014

CMPT 310 Assignment 1

Solving Sudoku Using Artificial Intelligence

Solving Nonograms by combining relaxations

MASTER PROOFS through GAMES

Episode 3 8 th 12 th February Substitution and Odd Even Variations By Kishore Kumar and Ashish Kumar

Episode 4 30 th March 2 nd April 2018 Odd Even & Substitution Variations By R Kumaresan and Amit Sowani

INSTRUCTION BOOKLET SUDOKU MASTERS 2008 NATIONAL SUDOKU CHAMPIONSHIP FINALS Q&A SESSION 10:30 10:50 PART 1 CLASSICS 11:00 11:35

Nested Monte-Carlo Search

CMPT 310 Assignment 1

Some results on Su Doku

The most difficult Sudoku puzzles are quickly solved by a straightforward depth-first search algorithm

INTRODUCTION TO COMPUTER SCIENCE I PROJECT 6 Sudoku! Revision 2 [2010-May-04] 1

Sudoku Solver Version: 2.5 Due Date: April 5 th 2013

Monthly Sudoku Contest for September th 17 th September Enthralling Sudoku By Ashish Kumar

Taking the Mystery Out of Sudoku Difficulty: An Oracular Model

RUBIK S CUBE SOLUTION

SUDOKU SURPRISE. Hosted by Logic Masters India November Puzzles set by David McNeill Tested by Tom Collyer, Yuhei Kusui and Robert Vollmert

Overview. Initial Screen

Standard Sudoku point. 1 point. P a g e 1

Foundations of Artificial Intelligence

An Exploration of the Minimum Clue Sudoku Problem

CS-171, Intro to A.I. Mid-term Exam Winter Quarter, 2015

WPF SUDOKU/PUZZLE GRAND PRIX 2014 WPF SUDOKU GP 2014 COMPETITION BOOKLET ROUND 4. Puzzle authors: Russia Andrey Bogdanov, Olga Leontieva.

Sudoku Tutor 1.0 User Manual

of Nebraska - Lincoln

2048: An Autonomous Solver

WPF SUDOKU/PUZZLE GRAND PRIX 2014 WPFSUDOKU GP 2014 COMPETITIONBOOKLET ROUND6. Puzzle authors: Bulgaria Deyan Razsadov.

Y8 & Y9 Number Starters A Spire Maths Activity

Logic Masters India Presents. April 14 16, 2012 April 2012 Monthly Sudoku Test INSTRUCTION BOOKLET

Part III F F J M. Name

Synthesizing Interpretable Strategies for Solving Puzzle Games

IN THIS ISSUE. Cave vs. Pentagroups

Informed search algorithms. Chapter 3 (Based on Slides by Stuart Russell, Richard Korf, Subbarao Kambhampati, and UW-AI faculty)

Using KenKen to Build Reasoning Skills 1

REVIEW ON LATIN SQUARE

CSE548, AMS542: Analysis of Algorithms, Fall 2016 Date: Sep 25. Homework #1. ( Due: Oct 10 ) Figure 1: The laser game.

Available online at ScienceDirect. Procedia Computer Science 36 (2014 )

8. You Won t Want To Play Sudoku Again

Kenken For Teachers. Tom Davis January 8, Abstract

For Better Brains. SUDOKU ROYALE! INSTRUCTION BOOK

Comparing Methods for Solving Kuromasu Puzzles

Applications of Advanced Mathematics (C4) Paper B: Comprehension INSERT WEDNESDAY 21 MAY 2008 Time:Upto1hour

DOWNLOAD OR READ : SUDOKU LARGE PRINT PUZZLE BOOK FOR ADULTS 200 MEDIUM PUZZLES PUZZLE BOOKS PLUS PDF EBOOK EPUB MOBI

Heuristic Search with Pre-Computed Databases

Algorithmique appliquée Projet UNO

A comparison of a genetic algorithm and a depth first search algorithm applied to Japanese nonograms

Grade 6 Math Circles March 7/8, Magic and Latin Squares

The Mathematics Behind Sudoku Laura Olliverrie Based off research by Bertram Felgenhauer, Ed Russel and Frazer Jarvis. Abstract

AI Plays Yun Nie (yunn), Wenqi Hou (wenqihou), Yicheng An (yicheng)

10/5/2015. Constraint Satisfaction Problems. Example: Cryptarithmetic. Example: Map-coloring. Example: Map-coloring. Constraint Satisfaction Problems

Heuristics & Pattern Databases for Search Dan Weld

sudoku 16x16 454BB8EA3E376999F4F40AF890078C0E Sudoku 16x16 1 / 6

Welcome to the Sudoku and Kakuro Help File.

Counting Sudoku Variants

Applications of Advanced Mathematics (C4) Paper B: Comprehension WEDNESDAY 21 MAY 2008 Time:Upto1hour

Modified Method of Generating Randomized Latin Squares

Design and Implementation of Game Based Security Model to Secure the Information Contents

Solving Sudoku with Genetic Operations that Preserve Building Blocks

Sudoku Touch. 1-4 players, adult recommended. Sudoku Touch by. Bring your family back together!

Fast Placement Optimization of Power Supply Pads

Hybridization of CP and VLNS for Eternity II.

Classic Sudoku 9x9 - Easy To Medium - Volume Logic Puzzles By Nick Snels READ ONLINE

CandyCrush.ai: An AI Agent for Candy Crush

An Empirical Evaluation of Policy Rollout for Clue

Part I: The Swap Puzzle

Conversion Masters in IT (MIT) AI as Representation and Search. (Representation and Search Strategies) Lecture 002. Sandro Spina

Section Marks Agents / 8. Search / 10. Games / 13. Logic / 15. Total / 46

puzzles may not be published without written authorization

A TREE-SEARCH BASED HEURISTIC FOR A COMPLEX STACKING PROBLEM WITH CONTINUOUS PRODUCTION AND RETRIEVAL

Jumbo Sudoku Extreme By Sudoku READ ONLINE

G53CLP Constraint Logic Programming

Automatically Generating Puzzle Problems with Varying Complexity

Experimental Comparison of Uninformed and Heuristic AI Algorithms for N Puzzle Solution

It Stands to Reason: Developing Inductive and Deductive Habits of Mind

WPF Sudoku Grand Prix 2013: Play-off Instructions

Monte Carlo based battleship agent

FEATURES 24 PUZZLES, ASSORTED MIX, MOSTLY THEMED ON 24 HPC. HINTS FOR EACH PUZZLE. SOLUTIONS FOR EACH PUZZLE.

COCI 2008/2009 Contest #3, 13 th December 2008 TASK PET KEMIJA CROSS MATRICA BST NAJKRACI

Transcription:

On the Combination of Constraint Programming and Stochastic Search: The Sudoku Case Rhydian Lewis Cardiff Business School Pryfysgol Caerdydd/ Cardiff University lewisr@cf.ac.uk

Talk Plan Introduction: What is Sudoku? Making and solving Sudoku puzzles A simple stochastic algorithm for Sudoku General characteristics of the algorithm Improving performance using constraintbased techniques Conclusions and further work

Introduction Example of an order- logicsolvable grid the st Century s Rubik s Cube Given a partially filled n x n grid, fill each of the blank cells so that each row, column, and box contains through to n exactly once. Order- grids are the most popular, though others are possible

Introduction Example of an order- logicsolvable grid the st Century s Rubik s Cube Given a partially filled n x n grid, fill each of the blank cells so that each row, column, and box contains through to n exactly once. Order- grids are the most popular, though others are possible

Introduction Example of an order- logicsolvable grid the st Century s Rubik s Cube Given a partially filled n x n grid, fill each of the blank cells so that each row, column, and box contains through to n exactly once. Order- grids are the most popular, though others are possible

Making and Solving Puzzles Example of an order- logic-solvable grid: There is a unique solution No guessing required The puzzle master should supply a logic-solvable puzzle Unique solution No guessing required (deductive techniques only) Computers can easily solve such puzzles www.sudokusolver.com www.scanraid.com Thus, only certain grid formations will constitute a good puzzle (from a human and/or solver s perspective)

Making and Solving Puzzles However, not all puzzles will be logic-solvable E.g. removing some numbers from the left grid may mean: Deductive rules are not enough; Searching/ guessing is required More than one solution Here all s have been removed: More than one solution Guessing may be required Logical solvers thus rely on being given good puzzles. Sudoku is an NP-complete puzzle. It also has an exponential search space. B&B is one possibility. But what about other types of search?

A Stochastic Search Method ) Take a valid Sudoku puzzle

A Stochastic Search Method ) Take a valid Sudoku puzzle ) Randomly add the missing values to each box and evaluate Column Scores Row Scores Cost

A Stochastic Search Method ) Take a valid Sudoku puzzle ) Randomly add the missing values to each box and evaluate ) Iteratively apply the neighbourhood operator and re-evaluate Column Scores Row Scores Cost

A Stochastic Search Method ) Take a valid Sudoku puzzle ) Randomly add the missing values to each box and evaluate ) Iteratively apply the neighbourhood operator and re-evaluate ) Stop when an optimal grid is found Problem instances do not have to be logic solvable for this algorithm to be able to find a solution Our particular algorithm made use of Simulated Annealing

Solving Published Puzzles run progress Order logic-solvable puzzles from a variety of newspapers quickly solved (less than seconds) cost No relationship with perceived difficulty rating Reheat occurs here Solution found here Order- puzzles typically solved in - seconds (some reheating needed occasionally) iterations (x) Example Run with an Order- ( x ) instance taken from The Wales on Sunday Only one solution in each case. In many cases, logic based algorithms are faster

Solving Random Puzzles Because the SA algorithm does not need a puzzle to be logic solvable, what does make an instance difficult to solve? A new method of puzzle generation was implemented: ) Take a complete and valid Sudoku puzzle

Solving Random Puzzles Because the SA algorithm does not need a puzzle to be logic solvable, what does make an instance difficult to solve? A new method of puzzle generation was implemented: ) Take a complete and valid Sudoku puzzle ) Alter the puzzle whilst keeping validity

Solving Random Puzzles Because the SA algorithm does not need a puzzle to be logic solvable, what does make an instance difficult to solve? A new method of puzzle generation was implemented: ) Take a complete and valid Sudoku puzzle ) Alter the puzzle whilst keeping validity ) Go through each cell and remove each entry with a probability p, (where p = [, ]). For low p s, Puzzles may have more than one solution Not necessarily logic solvable

Algorithm Performance for n = : i.e. ( x ) grids Solution solution time time (seconds)...... solution time success rate.... proportion fixed (p) Proportion of cells filled (p) Success success rate Rate (%) For low p s there are many different optimal solutions (,,,,,,, for p = ) For high p s the search space will be small and will have a strong basin of attraction Empty grids (large search space) Full grids (small search space)

Algorithm Performance for n = and n = n = (x grids) n = (x grids) solution time (seconds) success rate (%) solution time (seconds) success rate (%).... proportion of fixed cells (p) solution time success rate.... proportion of fixed cells (p) solution time success rate Similar patterns to n =, though a phase transition region is also visible The phase transition causes a fluctuation in both the success rate and solution time

Improving Algorithm Performance Phase transition seems to be caused by two factors: Relatively large search space, but very small number of solutions The moderate number of constraints will cause a more inhospitable cost landscape Q: Can we improve performance by adding a logicbased solver (constraint programming)? Proposed Hybrid Method Take problem instance Fill cells using a logical solver (reduce search space/ add constraints) Use stochastic search when the logic solver cannot fill any more cells Output result

Solving Random Instances prop. of fixed cells after CP procedure.... Performance of logic-based procedure On random instances of various p s no CP order- order- order-.... Empty grids prop. of fixed cells in problem instance (p) Full grids For p <. there are insufficient clues for any cells to be filled For p >., the procedure completes the puzzles. Between these values, some but not all cells are filled

Solving Random Instances: Hybrid Vs SA algorithm solution time (CPU seconds)..... Solution Time (SA) Success Rate (SA) Solution Time (Hybrid) Success Rate (Hybrid) n =... success rate solution time (CPU seconds) Solution Time (SA) Success Rate (SA) Solution Time (Hybrid) Success Rate (Hybrid) n =... success rate........... proportion of fixed cells (p) proportion of fixed cells (p) solution time (CPU seconds) Solution Time (SA) Success Rate (SA) Solution Time (Hybrid) Success Rate (Hybrid) n =........ success rate For p <. the algorithms are equivalent For p >. the hybrid algorithm has shorter run times Success rate of the hybrid algorithm is greater throughout the phase transition regions proportion of fixed cells (p)

Conclusions and Further Work Experiments have shown that the hybrid algorithm also outperforms the SA algorithm on many published, logic-solvable instances. The CP and stochastic algorithms seem to complement one another: improvements in one aspect should lead to enhanced overall performance CP procedure has the potential to move instances out of the phase transition region. Can it move other instances into the region?

Further Work Though Sudoku is a silly little problem, it does reflect aspects of real world problems: e.g. timetabling and scheduling. Sudoku can also be modelled as a graph colouring problem each of the n cells is a node; each entry {,,n } is a colour add edges between nodes to represent the constraints Can known graph colouring heuristics be employed to help solve Sudoku problems (and indeed, vice-versa)?

On the Combination of Constraint Programming and Stochastic Search: The Sudoku Case Rhydian Lewis Cardiff Business School Pryfysgol Caerdydd/ Cardiff University lewisr@cf.ac.uk