<br><font size=2 face="sans-serif">I should have added some more :-) :-)
to my note (and not mentioned Cplex).</font>
<br>
<br><font size=2 face="sans-serif">The purpose was to test N way branching
and cut branching - not really to obtain a Su Doku solver. &nbsp;In fact
I find it slightly worrying that such things exist :-)</font>
<br>
<br><font size=2 face="sans-serif">I agree all the 9 x 9 examples in newspapers
could be made to solve at root node. &nbsp;The 16 x 16 I tried did not
(using 0-9,A-F) but I was not using strongest formulation as I wanted some
branching.</font>
<br>
<br><font size=2 face="sans-serif">John Forrest</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Thorsten Koch &lt;koch@zib.de&gt;</b>
</font>
<br><font size=1 face="sans-serif">Sent by: coin-lpsolver-bounces@list.coin-or.org</font>
<p><font size=1 face="sans-serif">11/24/2005 12:38 PM</font>
<table border>
<tr valign=top>
<td bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to<br>
koch</font></div></table>
<br>
<td width=59%>
<table width=100%>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td valign=top><font size=1 face="sans-serif">coin-lpsolver@list.coin-or.org</font>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td valign=top>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td valign=top><font size=1 face="sans-serif">[Coin-lpsolver] Sudoku as
IP</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=2><tt>&gt; Message: 2<br>
&gt; Date: Thu, 24 Nov 2005 07:12:49 -0500<br>
&gt; From: John J Forrest &lt;jjforre@us.ibm.com&gt;<br>
&gt; Subject: [Coin-lpsolver] New branching ideas for Cbc<br>
&gt; Cc: coin-lpsolver@list.coin-or.org<br>
&gt; Message-ID:<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;OF1293B673.B49751B7-ON052570C3.003A1216-052570C3.0043151E@us.ibm.com&gt;<br>
&gt; Content-Type: text/plain; charset=&quot;us-ascii&quot;<br>
&gt; <br>
&gt; One reason for going to Cbc version 1.00 was to imply a more measured
set <br>
&gt; of changes. &nbsp;One exception I made was that of adding new branching
classes <br>
&gt; etc.<br>
&gt; <br>
&gt; I wanted to see if I could implement a Constraint Programming idea
such as <br>
&gt; &quot;All Different&quot; into Cbc; also I had been asked to make
sure N-way <br>
&gt; branching worked. &nbsp;Finally Irv Lustig had asked - &quot;What
can you do with <br>
&gt; Cbc that you can't do with Cplex?&quot;. &nbsp;On the way back from
INFORMS I was <br>
&gt; sitting next to a person solving Su Doku puzzles and I thought - can
you <br>
&gt; write a Su Doku solver with Cplex?<br>
&gt; <br>
&gt; If you live in the UK you must know what a Su Doku puzzle is, for
some <br>
&gt; others - for a 9 x 9 Su Doku puzzle you fill it in using numbers 1
to 9 <br>
&gt; and each row and column must be all different as must the obvious
3x3 <br>
&gt; squares.<br>
&gt; <br>
&gt; I have implemented CbcBranchAllDifferent which stops two general integer
<br>
&gt; variables being the same by imposing two branches x &lt;= y-1 and
x &gt;= y+1. <br>
&gt; Obviously users can modify this to obtain their own cut branch rules.
&nbsp;I <br>
&gt; have also put in a CglAllDifferent cut generator which fixes variables
<br>
&gt; based on the above logic. &nbsp;I may improve the speed of this later.<br>
&gt; <br>
&gt; I found that this was not sufficient to do well at the Independent
super <br>
&gt; Su Doku puzzles (16x16) for which there is a prize. &nbsp;This is
because <br>
&gt; general integer variables at a bound are not enough for the logical
<br>
&gt; fixing. &nbsp;So I have implemented N way branching so that we can
fix the <br>
&gt; general integer variables more easily. &nbsp;And while I was at it
I added a <br>
&gt; trivial CglStored cut class where the user can put any cuts and then
have <br>
&gt; them added in if they are violated and the obvious AllDifferent row
cuts <br>
&gt; could go there. &nbsp;To see more look at the sudoku.cpp example in
<br>
&gt; Cbc/Samples. &nbsp;There is also a simple nway.cpp example.<br>
&gt; <br>
Why doing so much work to solve Sudoku? <br>
I mean to have all-different is nice,<br>
but if you model Sudoku with binary<br>
variables any IP-Solver will easily solve them.<br>
In many cases in the preprocessor.<br>
<br>
Using the model below, I solved about 3000 Sudokus. <br>
I am still looking for a single instance were CPLEX has <br>
to branch to solve it. <br>
(If anybody has such an instance I would be <br>
interested to get it, preferable in line, i.e. ---5---678----8--3... format&quot;.<br>
<br>
param p := 3;<br>
<br>
set I := { 1 .. p*p };<br>
set M := { 1 .. p};<br>
<br>
var x[I * I * I] binary;<br>
<br>
# file: row col value<br>
set F := { read &quot;sudoku.dat&quot; as &quot;&lt;1n,2n,3n&gt;&quot;
comment &quot;#&quot; };<br>
<br>
subto c1: forall &lt;i,j&gt; in I*I do sum &lt;k&gt; in I : x[i,j,k] ==
1;<br>
subto c2: forall &lt;j,k&gt; in I*I do sum &lt;i&gt; in I : x[i,j,k] ==
1;<br>
subto c3: forall &lt;i,k&gt; in I*I do sum &lt;j&gt; in I : x[i,j,k] ==
1;<br>
<br>
subto c4: forall &lt;m,n,k&gt; in M*M*I do <br>
 &nbsp; sum &lt;i,j&gt; in M*M : x[(m-1)*p+i,(n-1)*p+j,k] == 1;<br>
<br>
# Fix the fixed values<br>
subto c5: forall &lt;i,j,k&gt; in F do x[i,j,k] == 1;<br>
<br>
Best regards,<br>
Thorsten Koch<br>
<br>
_______________________________________________<br>
Coin-lpsolver mailing list<br>
Coin-lpsolver@list.coin-or.org<br>
http://list.coin-or.org/mailman/listinfo/coin-lpsolver<br>
</tt></font>
<br>