Difference between revisions of "Constraint satisfaction problem"
From Sudopedia
Jump to navigationJump to search (Created page with "'''Constraint Satisfaction Problems''' can be solved using Donald Knuth’s Dancing Links algorithm. Another way to program Sudoku as a constraint satisfaction problem i...") |
|||
| Line 1: | Line 1: | ||
| − | '''Constraint Satisfaction Problems''' can be solved using | + | '''Constraint Satisfaction Problems''' can be solved using Donald Knuth’s [[Dancing Links]] algorithm. |
| − | Another way to | + | Another way to model Sudoku as a constraint‑satisfaction problem is to treat it as a [[Binary Integer Linear Program]]. |
| − | |||
| − | ; < | + | ; <code>x(i,j,k) = 0</code> |
| − | : if [[Cell|cell]] < | + | : if [[Cell|cell]] <code>(i, j)</code> in the [[Grid|grid]] is **not** equal to <code>k</code> |
| − | ; < | + | ; <code>x(i,j,k) = 1</code> |
| − | : if | + | : if cell <code>(i, j)</code> in the grid **is** equal to <code>k</code> |
| − | The | + | The cell‑[[Constraint|constraint]] is then: |
; Cell constraint | ; Cell constraint | ||
| − | : < | + | : ‘‘Sum over <code>k</code> of <code>x(i,j,k)</code> = 1 for all <code>i</code> and <code>j</code>.’’ |
| − | The | + | The remaining three constraints (row, column and block) can be expressed in the same way—as simple linear sums. |
Latest revision as of 19:30, 22 July 2025
Constraint Satisfaction Problems can be solved using Donald Knuth’s Dancing Links algorithm.
Another way to model Sudoku as a constraint‑satisfaction problem is to treat it as a Binary Integer Linear Program.
x(i,j,k) = 1- if cell
(i, j)in the grid **is** equal tok
The cell‑constraint is then:
- Cell constraint
- ‘‘Sum over
kofx(i,j,k)= 1 for alliandj.’’
The remaining three constraints (row, column and block) can be expressed in the same way—as simple linear sums.