[jboss-svn-commits] JBL Code SVN: r34194 - labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Rule_Engine.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jul 26 11:07:22 EDT 2010
Author: ge0ffrey
Date: 2010-07-26 11:07:21 -0400 (Mon, 26 Jul 2010)
New Revision: 34194
Modified:
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Rule_Engine/Section-The_Drools_Rule_Engine.xml
Log:
JBRULES-2591 docs which are both duplicate and dead: removing duplicated part of Chapter-Theory.xml
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Rule_Engine/Section-The_Drools_Rule_Engine.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Rule_Engine/Section-The_Drools_Rule_Engine.xml 2010-07-26 15:03:13 UTC (rev 34193)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Rule_Engine/Section-The_Drools_Rule_Engine.xml 2010-07-26 15:07:21 UTC (rev 34194)
@@ -932,125 +932,6 @@
</section>
<section>
- <title>Truth Maintenance with <indexterm>
- <primary>Logical Object</primary>
- </indexterm> Logical Objects</title>
-
- <para>After regular inserts you have to retract facts explicitly. With
- <emphasis>logical</emphasis> assertions, the fact that was asserted will
- be automatically
- retracted when the conditions that asserted it in the first place are no
- longer true. Actually, it's even cleverer then that, because it will be
- retracted only if there isn't any single condition that supports the
- logical assertion.</para>
-
- <para>Normal insertions are said to be <emphasis>stated</emphasis>, i.e.,
- just like the intuitive meaning of "stating a fact" implies. Using a
- <code>HashMap</code> and a counter, we track how many times a particular
- equality is <emphasis>stated</emphasis>; this means we count how many
- different instances are equal.</para>
-
- <para>When we <emphasis>logically</emphasis> insert an object during a
- RHS execution we are said to <emphasis>justify</emphasis> it, and it is
- considered to be justified by the firing rule. For each logical insertion
- there can only be one equal object, and each
- subsequent equal logical insertion increases the justification counter for
- this logical assertion. A justification is removed by the LHS of the
- creating rule becoming untrue, and the counter is decreased accordingly.
- As soon as we have no more justifications the logical object is
- automatically retracted.</para>
-
- <para>If we try to <emphasis>logically</emphasis> insert an object when
- there is an equal <emphasis>stated</emphasis> object, this will fail and
- return null. If we <emphasis>state</emphasis> an object that has an
- existing equal object that is <emphasis>justified</emphasis> we override
- the Fact; how this override works depends on the configuration setting
- <code>WM_BEHAVIOR_PRESERVE</code>. When the property is set to discard we use the
- existing handle and replace the existing instance with the new Object,
- which is the default behavior; otherwise we override it to
- <emphasis>stated</emphasis> but we create an new <code>FactHandle</code>.</para>
-
- <para>This can be confusing on a first read, so hopefully the flow charts
- below help. When it says that it returns a new <code>FactHandle</code>, this also
- indicates the <code>Object</code> was propagated through the network.</para>
-
- <figure>
- <title>Stated Insertion</title>
- <mediaobject>
- <imageobject>
- <imagedata align="center" fileref="images/Chapter-Rule_Engine/Stated_Assertion.png"
- format="PNG" />
- </imageobject>
- </mediaobject>
- </figure>
-
- <figure>
- <title>Logical Insertion</title>
- <mediaobject>
- <imageobject>
- <imagedata align="center" fileref="images/Chapter-Rule_Engine/Logical_Assertion.png"
- format="PNG" />
- </imageobject>
- </mediaobject>
- </figure>
-
- <section>
- <title>Example Scenario</title>
-
- <para>An example may make things clearer. Imagine a credit card
- processing application, processing transactions for a given account and
- we have a working memory accumulating knowledge about a single account
- transaction. The rule engine is doing its best to decide whether
- transactions are possibly fraudulent or not. Imagine that this rule base
- basically has rules that kick in when there is "reason to be suspicious"
- and when "everything is normal".</para>
-
- <para>Of course there are many rules that operate no matter what,
- performing standard calculations, etc. Now there are possibly many
- reasons as to what could trigger a "reason to be suspicious": someone
- notifying the bank, a sequence of large transactions, transactions for
- geographically disparate locations, or even reports of credit card theft.
- Rather then smattering all the little conditions in lots of rules,
- imagine there is a fact class called "SuspiciousAccount".</para>
-
- <para>Then there can be a series of rules whose job is to look for
- things that may raise suspicion, and if they fire, they
- <emphasis>logically</emphasis> insert a
- new SuspiciousAccount() instance. All the other rules just have
- conditions like "not SuspiciousAccount()" or "SuspiciousAccount()"
- depending on their needs. Note that this has the advantage of allowing
- there to be many rules around raising suspicion, without touching the
- other rules. After all the facts causing the SuspiciousAccount()
- insertion are removed, the account handling reverts to a normal
- mode of operation where, for instance, a rule with
- "not SuspiciousAccount()" may kick in, which flushes through any
- blocked transactions.</para>
-
- <para>If you have followed this far, you will note that truth
- maintenance, like logical assertions, allows rules to behave a little
- like a human would, and can certainly make the rules more
- manageable.</para>
- </section>
-
- <section>
- <title>Important note: Equality for Java objects</title>
-
- <para>It is important to note that for Truth Maintenance (and logical
- assertions) to work at all, your Fact objects (which may be JavaBeans)
- must override equals and hashCode methods (from java.lang.Object) correctly.
- As the truth maintenance system needs to know when two different physical
- objects are equal in value,
- <emphasis>both</emphasis> equals and hashCode must be overridden
- correctly, as per the Java standard.</para>
-
- <para>Two objects are equal if and only if their equals methods return
- true for each other and if their hashCode methods return the same
- values. See the Java API for more details (but do keep in mind you
- <emphasis>MUST</emphasis> override both equals and hashCode).</para>
- </section>
- </section>
-
- <section>
<title>Event Model</title>
<para>The event package provides means to be notified of rule engine
More information about the jboss-svn-commits
mailing list