Modeling Sudoku with Integer Programs - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Modeling Sudoku with Integer Programs

Description:

Sudoku. Fill in the cells in the 9 9 grid such that each row, each ... The Sudoku solution can be characterized using a set of linear constraints and ... – PowerPoint PPT presentation

Number of Views:743
Avg rating:3.0/5.0
Slides: 15
Provided by: dscs
Category:

less

Transcript and Presenter's Notes

Title: Modeling Sudoku with Integer Programs


1
Modeling Sudoku with Integer Programs
  • Karthik Natarajan
  • Department of Mathematics (NUS)

2
Sudoku
Fill in the cells in the 99 grid such that each
row, each column and each 33 sub-grid contains
numbers 1 to 9
Source http//sudoku.sourceforge.net/
3
One Approach Graph Coloring Problem
2
7
4
A node is a cell. An edge connects two cells that
cannot have the same number (color). Find a
9-coloring of a graph given a partial coloring.
4
Another Approach Integer Feasibility Problem
  • nn Sudoku with n m2 where m is positive
    integer.
  • (i,j) corresponds to row i and column j.
  • Two possible variable definitions

j
i
Cell (4,7)
5
Visualization of the Feasible Region
x12
x112
x11
x111
x13
x113
(Integer variables)
(Binary variables )
The Sudoku solution can be characterized using a
set of linear constraints and integer/binary
variables.
6
Sudoku Binary Integer Feasibility Problem
7
Sudoku Binary Integer Feasibility Problem
  • For a nn Sudoku
  • Total number of variables O(n3)
  • Total number of linear constraints O(n2)
  • Size of search space O( )
  • Integer programming solvers can quickly search
    over this large space in a smart manner.

8
Solving Integer Programs (IP) Branch and Bound
Solve linear program (LP) by relaxing x ? 0,1
to x ? 0,1. Branch on the non-integral variable
xijk 0
xijk 1
Branch at each node by solving LP relaxations.
Using bounding methods to prune, we converge to
integer solution.
Infeasible
Pruned
Feasible
LP Solved using simplex, interior point methods.
IP Solved using LP relaxations.
9
Using a Integer Programming Solver
  • Sudoku can be solved using general purpose IP
    solvers
  • - Xpress-MP
  • - ILOG OPL, CPLEX
  • - Excel
  • Objective function can be arbitrary since this is
    a feasibility problem.
  • The solver produces a feasible solution if it
    exists else it indicates infeasibility

10
Using the Xpress-MP solver
  • Free student edition of Xpress-MP can be
    downloaded from http//www.dashoptimization.com/h
    ome/products/evaluation/student_request.html
  • This can be used to solve small size
    problems.
  • User manual is available at
  • http//www.dashoptimization.com/home/services/pub
    lications/applications_book.html
  • Large problems can be solved with the Xpress-MP
    solver online at the NEOS server
  • http//neos.mcs.anl.gov/neos/solvers/index.html

11
Xpress-MP code sudokusolve.mos
12
Variants A 1616 Sudoku
Source http//sudoku.sourceforge.net/ (Tough)
13
Variants Sudoku X

The two main diagonals must also contains each of
the numbers from 1 to 9.
Source http//www.maa.org/editorial/mathgames/mat
hgames_09_05_05.html
14
Variants A Samurai Sudoku

Source http//www.samurai-sudoku.com/ 1
December 2006 (Fiendish)
Write a Comment
User Comments (0)
About PowerShow.com