SOLVING SUDOKU WITH MATLAB Raluca Marinescu, Andrea Garcia, Ivan Castro, Eduard Enoiu Mälardalen University, Västerås, 25.03.2011.

Slides:



Advertisements
Similar presentations
Lesson 12 Getting Started with Excel Essentials
Advertisements

RAPTOR Syntax and Semantics By Lt Col Schorsch
BUSINESS DRIVEN TECHNOLOGY Decision Analysis Tools in Excel
Decision Analysis Tools in Excel
Using Macros and Visual Basic for Applications (VBA) with Excel
Tutorial 8: Developing an Excel Application
Templates and Styles Excel Advanced. Templates are pre- designed and formatted spreadsheets –They provide consistency of layout/structure –They.
ACOT Intro/Copyright Succeeding in Business with Microsoft Excel 2010: Chapter1.
Microsoft Office 2007 Excel Chapter 8 Formula Auditing, Data Validation, and Complex Problem Solving.
CS 275Tidwell Course NotesPage 110 Chapter 7: Getting Input From Users Designing interactive forms, in which the user is expected to supply information.
1 CSE1301 Computer Programming: Lecture 23 Algorithm Design (Part 1)
A graphical user interface (GUI) is a pictorial interface to a program. A good GUI can make programs easier to use by providing them with a consistent.
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation. All.
1 of 6 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
Get number The ginput command creates crosshairs. When the user clicks the x,y values of the crosshairs are returned.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
A game of logic where the player must assign the numbers 1..9 to cells on a 9x9 grid. The placement of the numbers must be such that every number must.
Chapter 1 Program Design
3x3x3 Rubik’s Cube Solver Kevin Van Kammen Kyle Rupnow Jason Lavrenz.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Fundamentals of Python: From First Programs Through Data Structures
SudokuEHG Michelle Brown Matt Haggenmiller Thomas Troch CE Design Projects Design Review December 12, 2007.
SOLVING SUDOKU WITH MATLAB
SOLVING SUDOKU WITH MATLAB VERIFICATION FUNCTION correctness verification of the puzzle: checks if the current element appears twice in the same line,
SUDOKU Via Relaxation Labeling
Fundamentals of Python: First Programs
Excel Lesson 2 Business Forms. Task 1  Goals  Format cell data  Apply and modify cell styles.
1 CSC 427: Data Structures and Algorithm Analysis Fall 2011 See online syllabus (also available through BlueLine): Course goals:
Microsoft Excel Macros & Excel Solver (IENG490)
Using a Spreadsheet Chapter 5.
Each VI has 2 Windows Front Panel User Interface (UI) –Controls = Inputs –Indicators = Outputs Block Diagram Graphical Code –Data travels on wires from.
CTS130 Spreadsheet Lesson 3 Using Editing and Formatting Tools.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Creating a Web Site to Gather Data and Conduct Research.
Sudoku Taryn, Jin, Jehsang, Phil, and Matt. Outline What is Sudoku? –The game of Sudoku –The website Sudoku UI Prototype How to use the site (use cases)
Introduction to Matlab & Data Analysis
Basic layout for KS 2,3 and 4 starting point and rough layout Ability to switch between number line and graph Rule checking Mapping table with user entry.
Sudoku Hands-on Training Masters Project Presentation Yiqi Gao March 19, 2014.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Chapter 3: Using GUI Objects and the Visual Studio IDE.
Chapter 12: How Long Can This Go On?
GUI development with Matlab: GUI Front Panel Components 1 GUI front panel components In this section, we will look at -GUI front panel components -Programming.
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
Microsoft Office 2007 Access Chapter 3 Maintaining a Database.
Sudoku Solver Comparison A comparative analysis of algorithms for solving Sudoku.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
SOLVING SUDOKU WITH MATLAB Raluca Marinescu, Andrea Garcia, Ivan Castro, Eduard Enoiu Mälardalen University, Västerås,
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
11 Project 2 Temperature Conversion (Not graded).
1 CMPT 275 Software Engineering Requirements Analysis activity (use case diagrams, Class activity) Janice Regan,
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Introduction to Computer Programming
1 Lesson 12 Getting Started with Excel Essentials Computer Literacy BASICS: A Comprehensive Guide to IC 3, 3 rd Edition Morrison / Wells.
GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 1 Other GUI components In this section, we will.
1 CSC 427: Data Structures and Algorithm Analysis Fall 2006 See online syllabus (also available through Blackboard): Course goals:
Page Designer Storyboard J. A. Fitzpatrick December 2004.
AS Level ICT Data entry: Creating validation checks.
1 Using Conditional Formatting & Data Validation Applications of Spreadsheets.
Introduction to Matlab Module #10 Page 1 Introduction to Matlab Module #10 – Creating Graphical User Interfaces Topics 1.Overview of GUI Development using.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
Computers Are Your Future Tenth Edition Spotlight 5: Microsoft Office Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall1.
Various Problem Solving Approaches. Problem solving by analogy Very often problems can be solved by looking at similar problems. For example, consider.
Excel Tutorial 8 Developing an Excel Application
Assignment 4 For this assignment refer to the notes on MATLAB from an MIT course that you can find here (or at the original website, lectures 14, 15, 16).
BTEC Level 3 Subsidiary Diploma
Sudoku.
Presentation transcript:

SOLVING SUDOKU WITH MATLAB Raluca Marinescu, Andrea Garcia, Ivan Castro, Eduard Enoiu Mälardalen University, Västerås,

B ACKGROUND From the Japanese: ”SU”, means ”number” and ”DOKU”, means ”single”. The board is composed by a 9x9 grid, sub-divided into 9 squares containing a 3x3 grid. The purpose of the game is to insert numbers (1-9) in the board without repeating a number in each row, column or sub-square. Sudoku is classified as an NP-complete problem, which means there is no known efficient algorithm to solve the puzzles. It has led researchers to some advances in algorithm design and implementation.

G RAPHICAL U SER I NTERFACE Implemented using Matlab’s GUI Design Environment ( GUIDE ). Used drag & drop components to create the layout. Each component has: A list of properties that can be edited (color, size, position, etc) Callback functions to model its behavior. 4 Buttons 81 Textboxes 9 subsquares (different color)

R ANDOM B UTTON Objective Creates and displays a random game on the board. Selects a game from a database of several games. Characteristics The only button enabled when the application is started. Once a game has been displayed, the remaining buttons get enabled. Hint Cell (black) Empty Cell Hint cells cannot be modified by the user.

S OLVE B UTTON Objective: Solves the current game and displays the solution on the board. Three main steps: 1. Read the current game from the board and generate a numerical matrix of 81 elements. Empty cells are substituted by zeros. A validation of the input data is performed. * 2. Execute the Sudoku solver function, iSudokuALG, using the numerical matrix as an input. 3. Retrieve the solution provided by the Sudoku solver function and populate the board. * Only integer values from 1- 9 can be inserted in the cells. Solution Cell (red)

V ERIFY B UTTON Objective Examines the correctness of either a partial game or a complete game. In case of an incorrect game, the program will display a pop-up window with an error message. In case of a correct game a pop-up window will state this. In a partial game, the number of remaining empty cells will also be stated.

C LEAR B UTTON Objective It clears the board and disables all the buttons except the random button, returning the program to its initial state.

G AME D ATABASE Created in to have different games to be Microsoft Excel solved. Includes games of different levels of difficulty. The games are read when the GUI is initialized. The reading process is performed by means of MATLAB's built-in function xlsread. % Read predefined games from the input spreadsheet [num, cellMat]= xlsread('sudoku.xls', 'Games');

VERIFICATION FUNCTION correctness verification of the puzzle: checks if the current element appears twice in the same line, column, or in the 3-by-3 grid. Input: the cell matrix A which contains the current puzzle. Output: variable val which can have two values: 0 if the puzzle is correct 1 otherwise function [val]=verific(A)

ALGORITHM Based on constraint propagation The key internal function is: When a value is assigned to a cell that same value cannot be used as a possible assignment in all related cells; If a cell has only one single value for possible assignment, that value is immediately assigned. % Read predefined games and outputs the solved puzzle function [A]= iSudokuALG(A)

ALGORITHM Steps: 1. Find all the possible values for all the empty cells; 2. If there is a single possible value, we assign that value to the cell; 3. Propagate constraints to other cells until you reach the end of the puzzle; 4. If all the cells have more than one possible value we fill in a tentative value for that cell. 5. START AGAIN (When do we stop?)

ALGORITHM When do we stop? When there are no more empty cells in the puzzle; When for a cell we cannot place any possible value.

ALGORITHM TESTING Experimental results for different Sudoku puzzles:

C ONCLUSIONS Implementing a Sudoku solver in MATLAB allowed us to use many tools and built-in functions presented during the course. The combination of a simple, yet effective algorithm with a graphical user interface allowed us to generate games, solve them and verify the given solutions in a simple and quick way. Good communication and coordination among the team members made possible the completion of the project before the established deadline.