[jboss-svn-commits] JBL Code SVN: r27103 - labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jun 23 15:35:01 EDT 2009


Author: ge0ffrey
Date: 2009-06-23 15:35:01 -0400 (Tue, 23 Jun 2009)
New Revision: 27103

Added:
   labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Section-Benchmarking_and_tweaking.xml
Modified:
   labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Chapter-Solver.xml
   labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Section-Solver_configuration.xml
   labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Section-Solver_introduction.xml
Log:
JBRULES-2133 + benchmarker docs

Modified: labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Chapter-Solver.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Chapter-Solver.xml	2009-06-23 15:30:15 UTC (rev 27102)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Chapter-Solver.xml	2009-06-23 19:35:01 UTC (rev 27103)
@@ -15,6 +15,8 @@
 	<xi:include href="Section-Score_calculation.xml" />
 
 	<xi:include href="Section-Local_Search_Solver.xml" />
+
+	<xi:include href="Section-Benchmarking_and_tweaking.xml" />
 </chapter>
 
 

Added: labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Section-Benchmarking_and_tweaking.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Section-Benchmarking_and_tweaking.xml	                        (rev 0)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Section-Benchmarking_and_tweaking.xml	2009-06-23 19:35:01 UTC (rev 27103)
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<section version="5.0" xml:base="../../" xmlns="http://docbook.org/ns/docbook"
+         xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"
+         xmlns:svg="http://www.w3.org/2000/svg" xmlns:m="http://www.w3.org/1998/Math/MathML"
+         xmlns:html="http://www.w3.org/1999/xhtml" xmlns:db="http://docbook.org/ns/docbook">
+  <title>Benchmarking and tweaking</title>
+
+  <section>
+    <title>Finding the best configuration</title>
+
+    <para>Drools-solver supports several solver types, but you're probably wondering which is the best one? Although
+    some solver types generally perform better then others, it really depends on your problem domain. Most solver types
+    also have settings which can be tweaked. Those settings can influence the results of a solver a lot, although most
+    settings perform pretty good out-of-the-box.</para>
+
+    <para>Luckily, drools-solver includes with a benchmarker, which allows you to play out different solver types and
+    different settings against each other, so you can pick the best configuration for your problem domain.</para>
+  </section>
+
+  <section>
+    <title>Building a Benchmarker</title>
+
+    <para>You can build a <literal>Benchmarker</literal> instance with the <literal>XmlSolverBenchmarker</literal>.
+    Configure it with a benchmarker configuration xml file:</para>
+
+    <programlisting>    XmlSolverBenchmarker benchmarker = new XmlSolverBenchmarker();
+    benchmarker.configure("/org/drools/solver/examples/nqueens/benchmark/nqueensSolverBenchmarkConfig.xml");
+    benchmarker.benchmark();
+    behchmarker.writeResults(resultFile);</programlisting>
+
+    <para>A basic benchmarker configuration file looks something like this:</para>
+
+    <programlisting>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+&lt;solverBenchmarkSuite&gt;
+    &lt;solvedSolutionFilesDirectory&gt;local/data/nqueens/solved&lt;/solvedSolutionFilesDirectory&gt;
+
+    &lt;inheritedUnsolvedSolutionFile&gt;data/nqueens/unsolved/unsolvedNQueens32.xml&lt;/inheritedUnsolvedSolutionFile&gt;
+    &lt;inheritedUnsolvedSolutionFile&gt;data/nqueens/unsolved/unsolvedNQueens64.xml&lt;/inheritedUnsolvedSolutionFile&gt;
+    &lt;inheritedLocalSearchSolver&gt;
+        &lt;scoreDrl&gt;/org/drools/solver/examples/nqueens/solver/nQueensScoreRules.drl&lt;/scoreDrl&gt;
+        &lt;scoreDefinition&gt;
+            &lt;scoreDefinitionType&gt;SIMPLE&lt;/scoreDefinitionType&gt;
+        &lt;/scoreDefinition&gt;
+        &lt;finish&gt;
+            &lt;maximumSecondsSpend&gt;20&lt;/maximumSecondsSpend&gt;
+        &lt;/finish&gt;
+        &lt;selector&gt;
+            &lt;moveFactoryClass&gt;org.drools.solver.examples.nqueens.solver.move.factory.NQueensMoveFactory&lt;/moveFactoryClass&gt;
+        &lt;/selector&gt;
+        &lt;forager&gt;
+            &lt;foragerType&gt;MAX_SCORE_OF_ALL&lt;/foragerType&gt;
+        &lt;/forager&gt;
+    &lt;/inheritedLocalSearchSolver&gt;
+
+    &lt;solverBenchmark&gt;
+        &lt;name&gt;Solution tabu&lt;/name&gt;
+        &lt;localSearchSolver&gt;
+            &lt;accepter&gt;
+                &lt;completeSolutionTabuSize&gt;1000&lt;/completeSolutionTabuSize&gt;
+            &lt;/accepter&gt;
+        &lt;/localSearchSolver&gt;
+    &lt;/solverBenchmark&gt;
+    &lt;solverBenchmark&gt;
+        &lt;name&gt;Move tabu 5&lt;/name&gt;
+        &lt;localSearchSolver&gt;
+            &lt;accepter&gt;
+                &lt;completeMoveTabuSize&gt;5&lt;/completeMoveTabuSize&gt;
+            &lt;/accepter&gt;
+        &lt;/localSearchSolver&gt;
+    &lt;/solverBenchmark&gt;
+    &lt;solverBenchmark&gt;
+        &lt;name&gt;Move tabu 7&lt;/name&gt;
+        &lt;localSearchSolver&gt;
+            &lt;accepter&gt;
+                &lt;completeMoveTabuSize&gt;7&lt;/completeMoveTabuSize&gt;
+            &lt;/accepter&gt;
+        &lt;/localSearchSolver&gt;
+    &lt;/solverBenchmark&gt;
+    &lt;solverBenchmark&gt;
+        &lt;name&gt;Solution tabu and move tabu 7&lt;/name&gt;
+        &lt;localSearchSolver&gt;
+            &lt;accepter&gt;
+                &lt;completeSolutionTabuSize&gt;1000&lt;/completeSolutionTabuSize&gt;
+                &lt;completeMoveTabuSize&gt;7&lt;/completeMoveTabuSize&gt;
+            &lt;/accepter&gt;
+        &lt;/localSearchSolver&gt;
+    &lt;/solverBenchmark&gt;
+&lt;/solverBenchmarkSuite&gt;</programlisting>
+
+    <para>This benchmarker will try 4 configurations (1 solution tabu, 2 move tabu's and 1 solution-move tabu) on 2 data
+    sets (32 and 64 queens), so it will run 8 solvers.</para>
+
+    <para>Every <literal>solverBenchmark</literal> entity contains a solver configuration (for example a local search
+    solver) and one or more <literal>unsolvedSolutionFile</literal> entities. It will run the solver configuration on
+    each of those unsolved solution files. A <literal>name</literal> is optional and generated if absent. The common
+    part of multiple <literal>solverBenchmark</literal> entities can be extracted to the <literal>inherited</literal>
+    entities and can be overwritten per <literal>solverBenchmark</literal> entity.</para>
+
+    <para>If you specify a <literal>solvedSolutionFilesDirectory</literal> (relative to the working directory), the best
+    solution of each solver run will be written to that directory.</para>
+  </section>
+</section>


Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Section-Benchmarking_and_tweaking.xml
___________________________________________________________________
Name: svn:executable
   + *

Modified: labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Section-Solver_configuration.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Section-Solver_configuration.xml	2009-06-23 15:30:15 UTC (rev 27102)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Section-Solver_configuration.xml	2009-06-23 19:35:01 UTC (rev 27103)
@@ -20,8 +20,8 @@
 
       <itemizedlist>
         <listitem>
-          <para>It finds an optimal solution. If there is more then 1 optimal solution, it finds all optimal
-          solutions.</para>
+          <para>It knows when it has found an optimal solution. If there is more then 1 optimal solution, it finds all
+          optimal solutions.</para>
         </listitem>
 
         <listitem>
@@ -33,8 +33,8 @@
 
       <itemizedlist>
         <listitem>
-          <para>It has a horrible performance and scalability. Mostly unusable for a real-world problem due to time
-          constraints.</para>
+          <para>It performs and scales horribly. Mostly unusable for a real-world problem due to time
+          limitations.</para>
         </listitem>
       </itemizedlist>
 
@@ -52,34 +52,37 @@
 
       <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>
+          <para>It knows when it has found an optimal solution. If there is more then 1 optimal solution, it can find
+          all optimal solutions if needed.</para>
         </listitem>
+
+        <listitem>
+          <para>It can determine the bounds of a problem, which gives an indication of the quality of a solution.</para>
+        </listitem>
       </itemizedlist>
 
       <para>Disadvantages:</para>
 
       <itemizedlist>
         <listitem>
-          <para>It still scales very badly.</para>
+          <para>It still scales very badly. Mostly unusable for a real-world problem due to time limitations.</para>
         </listitem>
       </itemizedlist>
 
-      <para>Branch and bound is currently not implemented in drools-solver.</para>
+      <para>Branch and bound 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>Simplex</title>
 
-      <para>Simplex turns all constraints and data 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>Simplex is an algorithm to find the numerical solution of a linear programming problem.</para>
 
       <para>Advantages:</para>
 
       <itemizedlist>
         <listitem>
-          <para>It finds an optimal solution.</para>
+          <para>It knows when it has found an optimal solution.</para>
         </listitem>
       </itemizedlist>
 
@@ -87,19 +90,51 @@
 
       <itemizedlist>
         <listitem>
-          <para>It's usually rather complex and mathematical to implement constraints.</para>
+          <para>It's complex and mathematical to implement constraints.</para>
         </listitem>
       </itemizedlist>
 
-      <para>Drools-solver does not currently implement simplex.</para>
+      <para>Drools-solver does not implement simplex.</para>
     </section>
 
     <section>
+      <title>Genetic algorithms</title>
+
+      <para>Advantages:</para>
+
+      <itemizedlist>
+        <listitem>
+          <para>It's scalable</para>
+        </listitem>
+
+        <listitem>
+          <para>Given a limited time, it can still deliver a pretty decent solution.</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>The genetic algorithm is currently not implemented in drools-solver.</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 starts from an initial solution and evolves that single solution into a mostly better and
+      better solution. It uses a single search path of solutions, not a search tree. At each solution in this path it
+      evaluates a number of 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>
@@ -121,8 +156,7 @@
         </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>
+          <para>Given a limited time, it can still deliver a pretty decent solution.</para>
         </listitem>
       </itemizedlist>
 
@@ -144,6 +178,19 @@
   </section>
 
   <section>
+    <title>The size of real world problems</title>
+
+    <para>As a planning problem gets bigger, the search space tends to blow up really fast. It's not uncommon to see
+    that it's possible to optimally plan 5 people in less then a second, while planning 6 people optimally would take
+    years. Take a look at the problem size of the examples: many instances have a lot more possible solutions than there
+    are supposedly atoms in the known universe (10^80).</para>
+
+    <para>Planning competitions (such as the International Timetabling Competition) show that local search variations
+    (tabu search, simulated annealing, ...) usually perform best for real-world problems given real-world time
+    limitations.</para>
+  </section>
+
+  <section>
     <title>The Solver interface</title>
 
     <para>Every build-in solver implemented in drools-solver implements the <literal>Solver</literal> interface:</para>

Modified: labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Section-Solver_introduction.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Section-Solver_introduction.xml	2009-06-23 15:30:15 UTC (rev 27102)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-solver/src/main/docbook/en-US/Chapter-Solver/Section-Solver_introduction.xml	2009-06-23 19:35:01 UTC (rev 27103)
@@ -46,8 +46,8 @@
       </listitem>
 
       <listitem>
-        <para>Miss manners too (although drools-solver would solve this differently than the pure drools rule engine
-        example)</para>
+        <para>Miss manners too (although the drools-solver example solves this differently than the pure drools rule
+        engine example)</para>
       </listitem>
     </itemizedlist>
 
@@ -110,6 +110,8 @@
     occur. With the recipe called <filename>UpgradeFromPreviousVersionRecipe.txt</filename> you can easily upgrade and
     deal with any backwards incompatible changes between versions. You can find this recipe in subversion and in every
     release.</para>
+
+    <para>Drools-solver, like Drools, is open source software under the Apache Software License.</para>
   </section>
 
   <section>
@@ -185,11 +187,12 @@
     list</link>. You can read/write to the mailing list without littering your mailbox through <link
     xlink:href="nntp://news.gmane.org/gmane.comp.java.drools.user">this newsgroup</link>.</para>
 
-    <para>Feel free to report an issue in the drools-solver code or in this manual to <link
-    xlink:href="https://jira.jboss.org/jira/browse/JBRULES">the drools JIRA</link>. Select the component
-    <literal>drools-solver</literal>. </para>
+    <para>Feel free to report an issue (such as a bug, improvement or a new feature request) for the drools-solver code
+    or for this manual to <link xlink:href="https://jira.jboss.org/jira/browse/JBRULES">the drools JIRA</link>. Select
+    the component <literal>drools-solver</literal>.</para>
 
     <para>Patches are very welcome and get priority treatment! Attach them to a JIRA issue and optionally send a mail to
-    the dev list.</para>
+    the dev mailing list to get the issue fixed fast. By open sourcing your improvements, you 'll benefit from
+    improvements made upon your improvements.</para>
   </section>
 </section>




More information about the jboss-svn-commits mailing list