Exemplo n.º 1
0
 private void DeleteToken(ReteNode node, Token token)
 {
     if (node is Beta_Memory)
     {
         Beta_Memory b_node = (Beta_Memory)node;
         b_node.Items.Remove(token);
     }
     else if (node is P_Node)
     {
         P_Node p_node = (P_Node)node;
         //p_node.Items.Remove(tok);
         // foamliu, 2008/11/23, for publishing (de)activation events.
         p_node.RemoveToken(token);
     }
     else if (node is Negative_Node)
     {
         Negative_Node n_node = (Negative_Node)node;
         n_node.Items.Remove(token);
     }
     else if (node is NCC_Node)
     {
         NCC_Node ncc_node = (NCC_Node)node;
         ncc_node.Items.Remove(token);
     }
 }
Exemplo n.º 2
0
        private void P_NodeLeftActivation(P_Node p_Node, Token t, WME w)
        {
            // foamliu, 2008/08/26, otherwise we cannot delete token in p-node.
            Token new_token = Make_Token(p_Node, t, w);

            //p_Node.Items.Insert(0, new_token);
            // foamliu, 2008/11/23, for publishing (de)activation events.
            p_Node.InsertToken(new_token);
        }
Exemplo n.º 3
0
        //public void Add_Production(List<Condition> lhs)
        //{
        //    if (lhs == null || lhs.Count==0)
        //        return;

        //    //// dummy-top-node
        //    RETE_Node current_node = this.m_dummy_top_node;
        //    List<Condition> earlier_conditions = new List<Condition>();


        //    //Condition c0 = lhs[0];
        //    //List<Test_At_Join_Node> tests = Get_Join_Tests_From_Condition(c0, earlier_conditions);
        //    //Alpha_Memory am = Build_Or_Share_Alpha_Memory(c0);
        //    //current_node = Build_Or_Share_Join_Node(current_node, am, tests);

        //    //for (int i = 1; i < lhs.Count; i++)
        //    //{
        //    //    Condition ci = lhs[i];
        //    //    current_node = Build_Or_Share_Beta_Memory_Node(current_node);
        //    //    earlier_conditions.Add(lhs[i - 1]); // c(i-1)
        //    //    tests = Get_Join_Tests_From_Condition(ci, earlier_conditions);
        //    //    am = Build_Or_Share_Alpha_Memory(ci);
        //    //    current_node = Build_Or_Share_Join_Node(current_node, am, tests);
        //    //}

        //    current_node = Build_Or_Share_Network_For_Conditions(current_node, lhs, earlier_conditions);

        //    P_Node p_node = new P_Node();
        //    current_node.Children.Add(p_node);
        //    p_node.Parent = current_node;
        //    this.P_Nodes.Add(p_node);
        //    Update_New_Node_With_Matches_From_Above(p_node);
        //}

        public void AddProduction(Production prod)
        {
            ReteNode current_node = BuildOrShareNetworkForConditions(this.m_dummy_top_node, prod.LHS, new List <Condition>());

            // foamliu, 2008/11/21, more comments.
            // build a new production node
            P_Node p_node = new P_Node(prod);

            prod.P_Node = p_node;

            // make it a child of current node
            current_node.Children.Add(p_node);
            p_node.Parent = current_node;

            // foamliu, 2008/11/21, remove "P_Nodes", access p-nodes from productions.
            //this.P_Nodes.Add(p_node);
            UpdateNewNodeWithMatchesFromAbove(p_node);
        }