Example #1
0
 /// <summary>
 /// On a right activation of a negative node (when a WME is added to its alpha memory),
 /// we look for any tokens in its memory consistent with the WME; for each such token, we add
 /// this WME to its local result memory. Also, if the number of results changes from zero to
 /// one - indicating that the negated condition was previously true but is now false - then we
 /// call the delete-descendents-of-token helper function to delete any tokens lower in the network
 /// that depend on this token.
 /// </summary>
 /// <param name="node">The node.</param>
 /// <param name="w">The w.</param>
 private void negative_node_right_activation(NegativeNode node, WME w)
 {
     foreach (Token t in node.Items)
     {
         if (perform_join_tests(node.Tests, t, w))
         {
             if (t.JoinResults.Count == 0)
             {
                 delete_descendents_of_token(t);
             }
             NegativeJoinResult jr = new NegativeJoinResult();
             jr.Owner = t;
             jr.WME = w;
             t.JoinResults.AddToFront(jr);
             w.NegativeJoinResults.AddToFront(jr);
         }
     }
 }
Example #2
0
        /// <summary>
        /// On a left activation
        /// (when there is a new match for all the earlier conditions), we build and store a new token, perform
        /// a join for the token, store the join results in the token structure, and pass the token onto any
        /// successor nodes if there were no join results.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="t">The t.</param>
        /// <param name="w">The w.</param>
        private void negative_node_left_activation(NegativeNode node, Token t, WME w)
        {
            // *** Right Unlinking ***
            if (node.Items.Count == 0)
                relink_to_alpha_memory(node);
            // *** End Right Unlinking ***

            Token new_token = make_token(node, t, w);
            node.Items.AddToFront(new_token);
            foreach (ItemInAlphaMemory item in node.AlphaMemory.Items)
            {
                if (perform_join_tests(node.Tests, new_token, item.WME))
                {
                    NegativeJoinResult jr = new NegativeJoinResult();
                    jr.Owner = new_token;
                    jr.WME = w;
                    new_token.JoinResults.AddToFront(jr);
                    w.NegativeJoinResults.AddToFront(jr);
                }
            }
            if (new_token.JoinResults.Count == 0)
            {
                foreach (ReteNode child in node.Children)
                {
                    left_activation(child, new_token, null);
                }
            }
        }