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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Feb 17 11:23:05 EST 2008


Author: ge0ffrey
Date: 2008-02-17 11:23:03 -0500 (Sun, 17 Feb 2008)
New Revision: 18486

Modified:
   labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Local_Search_Solver.xml
   labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Score_calculation.xml
   labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Solver_configuration.xml
   labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Solver_examples.xml
   labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Solver_introduction.xml
Log:
Reverting irooskov's commit that deleted 3 months worth of changes and work

Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Local_Search_Solver.xml
===================================================================
--- labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Local_Search_Solver.xml	2008-02-16 08:38:51 UTC (rev 18485)
+++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Local_Search_Solver.xml	2008-02-17 16:23:03 UTC (rev 18486)
@@ -1,6 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-]>
 <section>
   <title>Local search solver</title>
 
@@ -34,9 +32,9 @@
 
     <para>An algorithm that checks every possible solution (even with pruning)
     can easily run for a couple of years on a single real-life planning
-    problem. Most of the time, we are happy with a feasible solution found in
+    problem. Most of the time, we 're happy with a feasible solution found in
     a limited amount of time. Local search tends to find a feasible solution
-    relatively fast. Because it acts very much like a human, it is also pretty
+    relatively fast. Because it acts very much like a human, it's also pretty
     natural to program.</para>
 
     <para>Local search solves a problem making a move on the current solution
@@ -81,6 +79,10 @@
 
       <mediaobject>
         <imageobject>
+          <imagedata fileref="singleMoveNQueens04.svg" format="SVG" />
+        </imageobject>
+
+        <imageobject>
           <imagedata fileref="singleMoveNQueens04.png" format="PNG" />
         </imageobject>
       </mediaobject>
@@ -270,6 +272,10 @@
 
       <mediaobject>
         <imageobject>
+          <imagedata fileref="possibleMovesNQueens04.svg" format="SVG" />
+        </imageobject>
+
+        <imageobject>
           <imagedata fileref="possibleMovesNQueens04.png" format="PNG" />
         </imageobject>
       </mediaobject>
@@ -334,6 +340,10 @@
 
       <mediaobject>
         <imageobject>
+          <imagedata fileref="decideNextStepNQueens04.svg" format="SVG" />
+        </imageobject>
+
+        <imageobject>
           <imagedata fileref="decideNextStepNQueens04.png" format="PNG" />
         </imageobject>
       </mediaobject>
@@ -355,6 +365,10 @@
 
       <mediaobject>
         <imageobject>
+          <imagedata fileref="allStepsNQueens04.svg" format="SVG" />
+        </imageobject>
+
+        <imageobject>
           <imagedata fileref="allStepsNQueens04.png" format="PNG" />
         </imageobject>
       </mediaobject>
@@ -400,6 +414,12 @@
     <para>Notice that the logging used the <literal>toString()</literal>
     method from our <literal>Move</literal> implementation: <literal>[Queen-1]
     1 @ 0 =&gt; 3</literal>.</para>
+
+    <para>The local search solver solves the 4 queens problem in 3 steps, by
+    evaluating only 37 possible solutions (3 steps with 12 moves each + 1
+    starting solution), which is only fraction of all 256 possible solutions.
+    It solves 16 queens in 31 steps, by evaluating only 7441 out of
+    18446744073709551616 possible solutions.</para>
   </section>
 
   <section>
@@ -460,6 +480,10 @@
 
       <mediaobject>
         <imageobject>
+          <imagedata fileref="decideNextStepNQueens04.svg" format="SVG" />
+        </imageobject>
+
+        <imageobject>
           <imagedata fileref="decideNextStepNQueens04.png" format="PNG" />
         </imageobject>
       </mediaobject>
@@ -649,6 +673,10 @@
 
         <para>Generates a random number for each accepted move and if it's
         below the move's accept chance, it picks it as the next move.</para>
+
+        <programlisting>    &lt;forager&gt;
+        &lt;foragerType&gt;FIRST_RANDOMLY_ACCEPTED&lt;/foragerType&gt;
+    &lt;/forager&gt;</programlisting>
       </section>
     </section>
   </section>
@@ -694,6 +722,12 @@
       <programlisting>    &lt;finish&gt;
         &lt;maximumHouresSpend&gt;1&lt;/maximumHouresSpend&gt;
     &lt;/finish&gt;</programlisting>
+
+      <para>Notice that if you use this finish, you will most likely sacrifice
+      reproducability. The best solution will depend on real-time process
+      speed, not only because it influences the amount of steps taken, but
+      also because time gradient based algoritms (such as simulated annealing)
+      will probably act differently on each run.</para>
     </section>
 
     <section>
@@ -761,4 +795,4 @@
       before finishing.</para>
     </section>
   </section>
-</section>
+</section>
\ No newline at end of file

Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Score_calculation.xml
===================================================================
--- labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Score_calculation.xml	2008-02-16 08:38:51 UTC (rev 18485)
+++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Score_calculation.xml	2008-02-17 16:23:03 UTC (rev 18486)
@@ -1,6 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-]>
 <section>
   <title>Score calculation with a rule engine</title>
 
@@ -20,11 +18,11 @@
       line</title>
 
       <programlisting>rule "multipleQueensHorizontal"
-  when
-    $q1 : Queen($id : id, $y : y);
-    $q2 : Queen(id &gt; $id, y == $y);
-  then
-    // trigger a change in the score
+    when
+        $q1 : Queen($id : id, $y : y);
+        $q2 : Queen(id &gt; $id, y == $y);
+    then
+        insertLogical(new UnweightedConstraintOccurrence("multipleQueensHorizontal", $q1, $q2));
 end</programlisting>
     </example>
 
@@ -39,6 +37,10 @@
 
       <mediaobject>
         <imageobject>
+          <imagedata fileref="unsolvedNQueens04.svg" format="SVG" />
+        </imageobject>
+
+        <imageobject>
           <imagedata fileref="unsolvedNQueens04.png" format="PNG" />
         </imageobject>
       </mediaobject>
@@ -144,29 +146,39 @@
     <programlisting>global SimpleScoreCalculator scoreCalculator;
 
 rule "multipleQueensHorizontal"
-  when
-    $q1 : Queen($id : id, $y : y);
-    $q2 : Queen(id &gt; $id, y == $y);
-  then
-    insertLogical(new WorkaroundMultiplePatternAccumulate("multipleQueensHorizontal", $q1, $q2));
+    when
+        $q1 : Queen($id : id, $y : y);
+        $q2 : Queen(id &gt; $id, y == $y);
+    then
+        insertLogical(new UnweightedConstraintOccurrence("multipleQueensHorizontal", $q1, $q2));
 end
 
+// multipleQueensVertical is obsolete because it is always 0
+
 rule "multipleQueensAscendingDiagonal"
-  // ...
+    when
+        $q1 : Queen($id : id, $ascendingD : ascendingD);
+        $q2 : Queen(id &gt; $id, ascendingD == $ascendingD);
+    then
+        insertLogical(new UnweightedConstraintOccurrence("multipleQueensAscendingDiagonal", $q1, $q2));
 end
 
 rule "multipleQueensDescendingDiagonal"
-  // ...
+    when
+        $q1 : Queen($id : id, $descendingD : descendingD);
+        $q2 : Queen(id &gt; $id, descendingD == $descendingD);
+    then
+        insertLogical(new UnweightedConstraintOccurrence("multipleQueensDescendingDiagonal", $q1, $q2));
 end
 
-rule "constraintsBroken"
-  when
-    $hardConstraintCount : Number() from accumulate(
-       $w : WorkaroundMultiplePatternAccumulate(),
-       count($w)
-    );
-  then
-    scoreCalculator.setScore(- $hardConstraintCount);
+rule "hardConstraintsBroken"
+    when
+        $occurrenceCount : Number() from accumulate(
+            $unweightedConstraintOccurrence : UnweightedConstraintOccurrence(),
+            count($unweightedConstraintOccurrence)
+        );
+    then
+        scoreCalculator.setScore(- $occurrenceCount.intValue());
 end</programlisting>
 
     <para>Optionally, you can also weigh your constraints differently, by
@@ -182,27 +194,27 @@
 
     <programlisting>// Warning: This currently triggers backwards chaining instead of forward chaining and seriously hurts performance and scalability.
 rule "constraintsBroken"
-  when
-    $multipleQueensHorizontal : Long()
-    from accumulate(
-        $q1 : Queen($id : id, $y : y)
-        and Queen(id &gt; $id, y == $y),
-       count($q1)
-    );
-    $multipleQueensAscendingDiagonal : Long()
-    from accumulate(
-        $q2 : Queen($id : id, $ascendingD : ascendingD)
-        and Queen(id &gt; $id, ascendingD == $ascendingD),
-       count($q2)
-    );
-    $multipleQueensDescendingDiagonal : Long()
-    from accumulate(
-        $q3 : Queen($id : id, $descendingD : descendingD)
-        and Queen(id &gt; $id, descendingD == $descendingD),
-       count($q3)
-    );
-  then
-    scoreCalculator.setScore(- (5 * $multipleQueensHorizontal) - $multipleQueensAscendingDiagonal - $multipleQueensDescendingDiagonal);
+    when
+        $multipleQueensHorizontal : Long()
+        from accumulate(
+            $q1 : Queen($id : id, $y : y)
+            and Queen(id &gt; $id, y == $y),
+           count($q1)
+        );
+        $multipleQueensAscendingDiagonal : Long()
+        from accumulate(
+            $q2 : Queen($id : id, $ascendingD : ascendingD)
+            and Queen(id &gt; $id, ascendingD == $ascendingD),
+           count($q2)
+        );
+        $multipleQueensDescendingDiagonal : Long()
+        from accumulate(
+            $q3 : Queen($id : id, $descendingD : descendingD)
+            and Queen(id &gt; $id, descendingD == $descendingD),
+           count($q3)
+        );
+    then
+        scoreCalculator.setScore(- (5 * $multipleQueensHorizontal) - $multipleQueensAscendingDiagonal - $multipleQueensDescendingDiagonal);
 end</programlisting>
   </section>
 
@@ -271,4 +283,4 @@
       </listitem>
     </itemizedlist>
   </section>
-</section>
+</section>
\ No newline at end of file

Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Solver_configuration.xml
===================================================================
--- labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Solver_configuration.xml	2008-02-16 08:38:51 UTC (rev 18485)
+++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Solver_configuration.xml	2008-02-17 16:23:03 UTC (rev 18486)
@@ -1,10 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-]>
 <section>
   <title>Solver configuration</title>
-<!--
-<section>
+
+  <section>
     <title>Types of solvers</title>
 
     <para>Different solvers solve problems in different ways. Each type has
@@ -155,7 +153,6 @@
       simulated annealing.</para>
     </section>
   </section>
--->
 
   <section>
     <title>The Solver interface</title>
@@ -272,6 +269,10 @@
 
       <mediaobject>
         <imageobject>
+          <imagedata fileref="unsolvedNQueens04.svg" format="SVG" />
+        </imageobject>
+
+        <imageobject>
           <imagedata fileref="unsolvedNQueens04.png" format="PNG" />
         </imageobject>
       </mediaobject>
@@ -286,10 +287,10 @@
 
     <programlisting>public interface Solution {
 
+    Collection&lt;? extends Object&gt; getFacts();
+
     Solution cloneSolution();
 
-    Collection&lt;? extends Object&gt; getFacts();
-
 }</programlisting>
 
     <para>For example:</para>
@@ -302,12 +303,28 @@
 
 }</programlisting>
 
-    <para>Most solvers use the <literal>cloneSolution()</literal> method to
-    clone the solution each time they encounter a new best solution. The
-    <literal>NQueens</literal> implementation just clones all
-    <literal>Queen</literal> instances:</para>
+    <section>
+      <title>The getFacts method</title>
 
-    <programlisting>    public NQueens cloneSolution() {
+      <para>All Objects returned by the <literal>getFacts()</literal> method
+      will be asserted into the drools working memory. Those facts can be used
+      by the score rules. For example, <literal>NQueens</literal> just returns
+      all <literal>Queen</literal> instances.</para>
+
+      <programlisting>    public Collection&lt;? extends Object&gt; getFacts() {
+        return queenList;
+    }</programlisting>
+    </section>
+
+    <section>
+      <title>The cloneSolution method</title>
+
+      <para>Most solvers use the <literal>cloneSolution()</literal> method to
+      clone the solution each time they encounter a new best solution. The
+      <literal>NQueens</literal> implementation just clones all
+      <literal>Queen</literal> instances:</para>
+
+      <programlisting>    public NQueens cloneSolution() {
         NQueens clone = new NQueens();
         List&lt;Queen&gt; clonedQueenList = new ArrayList&lt;Queen&gt;(queenList.size());
         for (Queen queen : queenList) {
@@ -317,13 +334,14 @@
         return clone;
     }</programlisting>
 
-    <para>The <literal>cloneSolution()</literal> method should clone no more
-    and no less than the parts of the <literal>Solution</literal> that can
-    change during solving. For example, in the lesson schedule example the
-    lessons are cloned, but teachers, groups and timeslots are not cloned
-    because only a lesson's appointed timeslot changes during solving:</para>
+      <para>The <literal>cloneSolution()</literal> method should clone no more
+      and no less than the parts of the <literal>Solution</literal> that can
+      change during solving. For example, in the lesson schedule example the
+      lessons are cloned, but teachers, groups and timeslots are not cloned
+      because only a lesson's appointed timeslot changes during
+      solving:</para>
 
-    <programlisting>    /**
+      <programlisting>    /**
      * Clone will only deep copy the lessons
      */
     public LessonSchedule cloneSolution() {
@@ -338,15 +356,7 @@
         clone.lessonList = clonedLessonList;
         return clone;
     }</programlisting>
-
-    <para>All Objects returned by the <literal>getFacts()</literal> method
-    will be asserted into the drools working memory. Those facts can be used
-    by the score rules. For example, <literal>NQueens</literal> just returns
-    all <literal>Queen</literal> instances.</para>
-
-    <programlisting>    public Collection&lt;? extends Object&gt; getFacts() {
-        return queenList;
-    }</programlisting>
+    </section>
   </section>
 
   <section>
@@ -372,6 +382,10 @@
 
       <mediaobject>
         <imageobject>
+          <imagedata fileref="solvedNQueens04.svg" format="SVG" />
+        </imageobject>
+
+        <imageobject>
           <imagedata fileref="solvedNQueens04.png" format="PNG" />
         </imageobject>
       </mediaobject>
@@ -380,4 +394,4 @@
     <para>After a problem is solved, you can reuse the same solver instance to
     solve another problem (of the same problem type).</para>
   </section>
-</section>
+</section>
\ No newline at end of file

Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Solver_examples.xml
===================================================================
--- labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Solver_examples.xml	2008-02-16 08:38:51 UTC (rev 18485)
+++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Solver_examples.xml	2008-02-17 16:23:03 UTC (rev 18486)
@@ -1,6 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-]>
 <section>
   <title>Solver examples</title>
 
@@ -789,4 +787,4 @@
       </table>
     </section>
   </section>
-</section>
+</section>
\ No newline at end of file

Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Solver_introduction.xml
===================================================================
--- labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Solver_introduction.xml	2008-02-16 08:38:51 UTC (rev 18485)
+++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Solver/Section-Solver_introduction.xml	2008-02-17 16:23:03 UTC (rev 18486)
@@ -1,6 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-]>
 <section>
   <title>Solver introduction</title>
 
@@ -35,7 +33,7 @@
       <listitem>
         <para><ulink
         url="http://en.wikipedia.org/wiki/Travelling_salesman_problem">The
-        traveling salesmen problem</ulink></para>
+        traveling salesman problem</ulink></para>
       </listitem>
 
       <listitem>
@@ -121,7 +119,7 @@
   </section>
 
   <section>
-    <title>Getting started with the examples</title>
+    <title>Building drools-solver and running an example</title>
 
     <para>No releases have been made yet, but you can easily build it from
     source yourself. Check out drools from subversion and do a maven 2 build
@@ -133,390 +131,31 @@
 $ mvn -Psolver -Dmaven.test.skip clean install
 ...</programlisting>
 
-    <para>Now you will If you want to use a stable version of drools, add this
-    /drools-solver/pom.xml </para>
+    <para>After that, you can run any example directly from the command line,
+    for example to run the n queens example, run:</para>
 
-    <para>After that, you can run any example directly from the command line
-    like this:</para>
-
     <programlisting>$ cd drools-solver/drools-solver-examples/
 $ mvn exec:exec -Dexec.mainClass="org.drools.solver.examples.nqueens.app.NQueensApp"
-...
-$ mvn exec:exec -Dexec.mainClass="org.drools.solver.examples.lessonschedule.app.LessonScheduleApp"
-...
-$ mvn exec:exec -Dexec.mainClass="org.drools.solver.examples.travelingtournament.app.simple.SimpleTravelingTournamentApp"
-...
-$ mvn exec:exec -Dexec.mainClass="org.drools.solver.examples.travelingtournament.app.smart.SmartTravelingTournamentApp"
 ...</programlisting>
 
-    <para>You will use the latest, unstable revision of drools. If you would
-    rather use a stable version of drools, edit
-    <literal>/drools-solver/drools-solver-examples/pom.xml</literal> and
-    overwrite the drools jar versions, before runing the example:</para>
+    <para>You will use drools-solver with the latest, unstable snapshot of the
+    drools rule engine. If you would rather use a stable version of the drools
+    rule engine, edit <literal>/drools-solver/pom.xml</literal> and overwrite
+    the drools jar versions, before building and running the examples:</para>
 
-    <programlisting>    &lt;dependencies&gt;
-        &lt;dependency&gt;
-            &lt;groupId&gt;org.drools&lt;/groupId&gt;
-            &lt;artifactId&gt;drools-core&lt;/artifactId&gt;
-            &lt;version&gt;4.0.2&lt;/version&gt;
-        &lt;/dependency&gt;
-        &lt;dependency&gt;
-            &lt;groupId&gt;org.drools&lt;/groupId&gt;
-            &lt;artifactId&gt;drools-compiler&lt;/artifactId&gt;
-            &lt;version&gt;4.0.2&lt;/version&gt;
-        &lt;/dependency&gt;
-
-        ...
-
-     &lt;/dependencies&gt;</programlisting>
-
-    <para>Here's a screenshot of the n queens example, which is a simple
-    example:</para>
-
-    <mediaobject>
-      <imageobject>
-        <imagedata fileref="screenshotSolvedNQueens8.png" format="PNG" />
-      </imageobject>
-    </mediaobject>
+    <programlisting>    &lt;dependencyManagement&gt;
+        &lt;dependencies&gt;
+            &lt;dependency&gt;
+                &lt;groupId&gt;org.drools&lt;/groupId&gt;
+                &lt;artifactId&gt;drools-core&lt;/artifactId&gt;
+                &lt;version&gt;4.0.3&lt;/version&gt;
+            &lt;/dependency&gt;
+            &lt;dependency&gt;
+                &lt;groupId&gt;org.drools&lt;/groupId&gt;
+                &lt;artifactId&gt;drools-compiler&lt;/artifactId&gt;
+                &lt;version&gt;4.0.3&lt;/version&gt;
+            &lt;/dependency&gt;
+        &lt;/dependencies&gt;
+    &lt;/dependencyManagement&gt;</programlisting>
   </section>
-
-  <section>
-    <title>The 4 queens example</title>
-
-    <section>
-      <title>Problem statement</title>
-
-      <para>The <emphasis>n queens puzzle</emphasis> 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 a queen can
-          attack any other queen on the same horizontal, vertical or diagonal
-          line.</para>
-        </listitem>
-      </itemizedlist>
-
-      <para>The most common n queens puzzle is the 8 queens puzzle, with
-      <emphasis>n = 8</emphasis>. We 'll explain drools-solver using the 4
-      queens puzzle as the primary example.</para>
-
-      <para>A proposed solution could be:</para>
-
-      <figure>
-        <title>A wrong solution for the 4 queens puzzle</title>
-
-        <mediaobject>
-          <imageobject>
-            <imagedata align="center"
-                       fileref="partiallySolvedNQueens04Explained.png"
-                       format="PNG" />
-          </imageobject>
-        </mediaobject>
-      </figure>
-
-      <para>The above solution is wrong because queens A1 and B0 can attack
-      each other (as can queens B0 and D0). Removing queen B0 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 for the 4 queens puzzle</title>
-
-        <mediaobject>
-          <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. We 'll
-      focus on finding a single correct solution for a given n, not on finding
-      the number of possible correct solutions for a given n.</para>
-    </section>
-
-    <section>
-      <title>Class diagram</title>
-
-      <para>Use a good domain model and it will be easier to understand and
-      solve your problem with drools-solver. We 'll use this domain model for
-      the n queens example:</para>
-
-      <figure>
-        <title>NQueens domain diagram</title>
-
-        <mediaobject>
-          <imageobject>
-            <imagedata align="center" fileref="nQueensDomainDiagram.png"
-                       format="PNG" />
-          </imageobject>
-        </mediaobject>
-      </figure>
-
-      <para>A <literal>Queen</literal> instance has an x (its column, for
-      example: 0 is column A, 1 is column B, ...) and a y (its row, for
-      example: 0 is row 0, 1 is row 1, ...). 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>
-
-      <table>
-        <title>A solution for the 4 queens puzzle shown in the domain
-        model</title>
-
-        <tgroup cols="6">
-          <thead>
-            <row>
-              <entry align="center">A solution</entry>
-
-              <entry align="center">Queen</entry>
-
-              <entry>x</entry>
-
-              <entry>y</entry>
-
-              <entry>ascendingD (x + y)</entry>
-
-              <entry>descendingD (x - y)</entry>
-            </row>
-          </thead>
-
-          <tbody>
-            <row>
-              <entry morerows="3"><mediaobject>
-                  <imageobject>
-                    <imagedata fileref="partiallySolvedNQueens04Explained.png"
-                               format="PNG" />
-                  </imageobject>
-                </mediaobject></entry>
-
-              <entry>A1</entry>
-
-              <entry>0</entry>
-
-              <entry>1</entry>
-
-              <entry>1 (**)</entry>
-
-              <entry>-1</entry>
-            </row>
-
-            <row>
-              <entry>B0</entry>
-
-              <entry>1</entry>
-
-              <entry>0 (*)</entry>
-
-              <entry>1 (**)</entry>
-
-              <entry>1</entry>
-            </row>
-
-            <row>
-              <entry>C2</entry>
-
-              <entry>2</entry>
-
-              <entry>2</entry>
-
-              <entry>4</entry>
-
-              <entry>0</entry>
-            </row>
-
-            <row>
-              <entry>D0</entry>
-
-              <entry>3</entry>
-
-              <entry>0 (*)</entry>
-
-              <entry>3</entry>
-
-              <entry>3</entry>
-            </row>
-          </tbody>
-        </tgroup>
-      </table>
-
-      <para>A single <literal>NQueens</literal> instance contains a list of
-      all <literal>Queen</literal> instances. It is the
-      <literal>Solution</literal> implementation which will be supplied to and
-      retrieved from drools-solver. Notice that in the 4 queens example,
-      NQueens's <literal>getN()</literal> method 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-examples src
-      distribution.</para>
-    </section>
-  </section>
-
-  <section>
-    <title>Types of solvers</title>
-
-    <para>Different solvers solve problems in different ways. Each type has
-    advantages and disadvantages. We 'll roughly discuss a few of the solver
-    types here. You can safely skip this section.</para>
-
-    <section>
-      <title>Brute force</title>
-
-      <para>Brute force creates and evaluates every possible solution, usually
-      by creating a search tree.</para>
-
-      <para>Advantages:</para>
-
-      <itemizedlist>
-        <listitem>
-          <para>It finds an optimal solution. If there is more then 1 optimal
-          solution, it finds all optimal solutions.</para>
-        </listitem>
-
-        <listitem>
-          <para>It is straightforward and simple to implement.</para>
-        </listitem>
-      </itemizedlist>
-
-      <para>Disadvantages:</para>
-
-      <itemizedlist>
-        <listitem>
-          <para>It has a horrible performance and scalability. Mostly unusable
-          for a real-world problem due to time constraints.</para>
-        </listitem>
-      </itemizedlist>
-
-      <para>Brute force is currently not implemented in drools-solver. But we
-      have plans to implement it in the future, as a reference for validating
-      the output of the other solver types.</para>
-    </section>
-
-    <section>
-      <title>Branch and bound</title>
-
-      <para>Branch and bound is an improvement over brute force, as it prunes
-      away subsets of solutions which cannot have a better solution than the
-      best solution already found at that point.</para>
-
-      <para>Advantages:</para>
-
-      <itemizedlist>
-        <listitem>
-          <para>It finds an optimal solution. If there is more then 1 optimal
-          solution, it can find all optimal solutions if needed.</para>
-        </listitem>
-      </itemizedlist>
-
-      <para>Disadvantages:</para>
-
-      <itemizedlist>
-        <listitem>
-          <para>It still scales very badly.</para>
-        </listitem>
-      </itemizedlist>
-
-      <para>Branch and bound is currently not implemented in
-      drools-solver.</para>
-    </section>
-
-    <section>
-      <title>Simplex</title>
-
-      <para>Simplex turns all constraints into a big equation, which it
-      transmutes into a mathematical function without local optima. It then
-      finds an optimal solution to the planning problem by finding an optima
-      of that mathematical function.</para>
-
-      <para>Advantages:</para>
-
-      <itemizedlist>
-        <listitem>
-          <para>It finds an optimal solution.</para>
-        </listitem>
-      </itemizedlist>
-
-      <para>Disadvantages:</para>
-
-      <itemizedlist>
-        <listitem>
-          <para>It's usually rather complex and mathematical to implement
-          constraints.</para>
-        </listitem>
-      </itemizedlist>
-
-      <para>Drools-solver does not currently implement simplex.</para>
-    </section>
-
-    <section>
-      <title>Local search (tabu search, simulated annealing, ...)</title>
-
-      <para>Local search starts from an initial solution and evolves that
-      single solution into a better and better solution. It uses a single
-      search path of solutions. At each solution in this path it evaluates a
-      number of possible moves on the solution and applies the most suitable
-      move to take the step to the next solution.</para>
-
-      <para>Local search works a lot like a human planner: it uses a single
-      search path and moves facts around to find a good feasible
-      solution.</para>
-
-      <para>A simple local search can easily get stuck in a local optima, but
-      improvements (such as tabu search and simulated annealing) address this
-      problem.</para>
-
-      <para>Advantages:</para>
-
-      <itemizedlist>
-        <listitem>
-          <para>It's relatively simple and natural to implement constraints
-          (at least in drools-solver's implementation).</para>
-        </listitem>
-
-        <listitem>
-          <para>It's very scalable, even when adding extra constraints (at
-          least in drools-solver's implementation).</para>
-        </listitem>
-
-        <listitem>
-          <para>It generally needs to worry about less negative hard
-          constraints, because the move pattern can fulfill a number of the
-          negative hard constraints.</para>
-        </listitem>
-      </itemizedlist>
-
-      <para>Disadvantages:</para>
-
-      <itemizedlist>
-        <listitem>
-          <para>It does not know when it has found an optimal solution.</para>
-        </listitem>
-
-        <listitem>
-          <para>If the optimal score is unknown (which is usually the case),
-          it must be told when to stop looking (for example based on time
-          spend, user input, ...).</para>
-        </listitem>
-      </itemizedlist>
-
-      <para>Drools-solver implements local search, including tabu search and
-      simulated annealing.</para>
-    </section>
-  </section>
-</section>
+</section>
\ No newline at end of file




More information about the jboss-svn-commits mailing list