[jboss-svn-commits] JBL Code SVN: r14877 - labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Sep 4 16:11:28 EDT 2007


Author: ge0ffrey
Date: 2007-09-04 16:11:27 -0400 (Tue, 04 Sep 2007)
New Revision: 14877

Added:
   labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-What_is_a_Solver.xml
   labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/nQueensDomainDiagram.dia
   labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/nQueensDomainDiagram.png
Log:
What is a solver documentation

Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-What_is_a_Solver.xml
===================================================================
--- labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-What_is_a_Solver.xml	                        (rev 0)
+++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-What_is_a_Solver.xml	2007-09-04 20:11:27 UTC (rev 14877)
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<section>
+  <title>What is a Solver?</title>
+
+  <section>
+    <title>Introduction</title>
+
+    <para>A solver solves all kinds of planning problems. Good examples of
+    such planning problems include:</para>
+
+    <itemizedlist>
+      <listitem>
+        <para>Employee shift rostering</para>
+      </listitem>
+
+      <listitem>
+        <para>Freight routing</para>
+      </listitem>
+
+      <listitem>
+        <para>Supply sorting</para>
+      </listitem>
+
+      <listitem>
+        <para>Lesson scheduling</para>
+      </listitem>
+
+      <listitem>
+        <para>Exam scheduling</para>
+      </listitem>
+
+      <listitem>
+        <para><ulink
+        url="http://en.wikipedia.org/wiki/Travelling_salesman_problem">The
+        traveling salesmen problem</ulink></para>
+      </listitem>
+
+      <listitem>
+        <para><ulink url="http://mat.gsia.cmu.edu/TOURN/">The traveling
+        tournament problem</ulink></para>
+      </listitem>
+
+      <listitem>
+        <para>Miss manners too (although drools-solver would solve this
+        differently then the pure drools rule engine example)</para>
+      </listitem>
+    </itemizedlist>
+
+    <para>todo ggg</para>
+  </section>
+
+  <section>
+    <title>Types of solvers</title>
+
+    <para>todo ggg</para>
+  </section>
+
+  <section>
+    <title>The 4 queens example</title>
+
+    <section>
+      <title>Problem statement</title>
+
+      <para>The n queens puzzle is a puzzle with the follow
+      constraints:</para>
+
+      <itemizedlist>
+        <listitem>
+          <para>Use a chessboard of n rows and n columns.</para>
+        </listitem>
+
+        <listitem>
+          <para>Place n queens on the chessboard.</para>
+        </listitem>
+
+        <listitem>
+          <para>No 2 queens can attack each other. Note that queens can attack
+          horizontally, vertically or diagonally.</para>
+        </listitem>
+      </itemizedlist>
+
+      <para>The most common puzzle is for <emphasis>n = 8</emphasis>, so the 8
+      queens puzzle. This manual explains drools-solver using the 4 queens
+      puzzle as it primary example.</para>
+
+      <para>A prosoded solution could be:</para>
+
+      <figure>
+        <title>A wrong solution of the 4 queens puzzle</title>
+
+        <mediaobject>
+          <imageobject>
+            <imagedata align="center"
+                       fileref="partiallySolvedNQueens04Explained.svg"
+                       format="SVG" />
+          </imageobject>
+
+          <imageobject>
+            <imagedata align="center"
+                       fileref="partiallySolvedNQueens04Explained.png"
+                       format="PNG" />
+          </imageobject>
+        </mediaobject>
+      </figure>
+
+      <para>The above solution is wrong because queens A1 and B1 can attack
+      each other (as can queens B1 and D1). Removing queen B1 would respect
+      the "no 2 queens can attack each other" constraint, but would break the
+      "place n queens" constraint.</para>
+    </section>
+
+    <section>
+      <title>Solution(s)</title>
+
+      <para>Below is a correct solution:</para>
+
+      <figure>
+        <title>A correct solution of the 4 queens puzzle</title>
+
+        <mediaobject>
+          <imageobject>
+            <imagedata align="center" fileref="solvedNQueens04.svg"
+                       format="SVG" />
+          </imageobject>
+
+          <imageobject>
+            <imagedata align="center" fileref="solvedNQueens04.png"
+                       format="PNG" />
+          </imageobject>
+        </mediaobject>
+      </figure>
+
+      <para>All the constraints have been met so the solution is correct. Note
+      that most n queens puzzles have multiple correct solutions. The example
+      in this manual focusses on finding a single correct solution, not on
+      finding the number of possible correct solutions for a given n.</para>
+    </section>
+
+    <section>
+      <title>Class diagram</title>
+
+      <para>Using a good domain model will make it easier to understand and
+      solve your problem with drools-solver. The 4 queens example uses this
+      domain model:</para>
+
+      <figure>
+        <title>NQueens domain diagram</title>
+
+        <mediaobject>
+          <imageobject>
+            <imagedata align="center" fileref="nQueensDomainDiagram.png"
+                       format="PNG" />
+          </imageobject>
+        </mediaobject>
+      </figure>
+
+      <para>A Queen instance has an <emphasis>x</emphasis> (its column, for
+      example 2 for column B) and a <emphasis>y</emphasis> (its row, for
+      example 3 for row 3). Based on the x and y, the ascending diagonal line
+      as well as the descending diagonal line can be calculated. The x and y
+      indexes start from the upper left corner of the chessboard.</para>
+
+      <para>A singleton NQueens instance contains a list of all Queens. Notice
+      that in the 4 queens example, NQueens.getN() will always return
+      4.</para>
+
+      <para>You can find the source code of this example (as well as well as
+      several other examples) in the drools-solver src distribution.</para>
+    </section>
+  </section>
+</section>
\ No newline at end of file

Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/nQueensDomainDiagram.dia
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/nQueensDomainDiagram.dia
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/nQueensDomainDiagram.png
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/nQueensDomainDiagram.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream




More information about the jboss-svn-commits mailing list