Esempio n. 1
0
        /// <summary>
        /// Binds the RHS.
        /// </summary>
        private void BindRHS(List <Activation> items)
        {
            int lhsCnt = _lhs.Count - 1;

            foreach (Activation act in items)
            {
                foreach (RightHandSideCondition condition in _rhs)
                {
                    WME newfact = new WME();
                    for (int f = 0; f < 3; f++)
                    {
                        Term term = condition.Fields[f];
                        if (term.TermType == TermType.Variable)
                        {
                            for (int i = lhsCnt; i >= 0; i--)
                            {
                                Condition rh = _lhs[i];
                                if (rh.ConditionType == ConditionType.Positive)
                                {
                                    int pos = rh.Contains(term);
                                    if (pos >= 0)
                                    {
                                        newfact.Fields[f] = act.InferredFact[pos];
                                        i = -1;
                                    }
                                }
                            }
                        }
                        else
                        {
                            newfact.Fields[f] = term;
                        }
                    }
                    Activation newact = new Activation(newfact, condition.ConditionType);
                    if (_inferredFacts.Contains(newact) == false)
                    {
                        _inferredFacts.Add(newact);
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ActivationEvent"/> class.
 /// </summary>
 /// <param name="activation">The activation.</param>
 public ActivationEvent(Activation activation)
 {
     Activation = activation;
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ActivationEvent"/> class.
 /// </summary>
 /// <param name="activation">The activation.</param>
 public ActivationEvent(Activation activation)
 {
     Activation = activation;
 }
Esempio n. 4
0
        /// <summary>
        /// P_node_activations the specified node.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="tok">The tok.</param>
        /// <param name="w">The w.</param>
        private void p_node_activation(ProductionNode node, Token tok, WME w)
        {
            Token new_token = make_token(node, tok, w);
            node.Items.AddToFront(new_token);

            int lhsCnt = node.Production.Lhs.Count - 1;

            foreach (RightHandSideCondition rhsCondition in node.Production.Rhs)
            {
                WME newfact = new WME();
                for (int f = 0; f < 3; f++)
                {
                    Term term = rhsCondition.Fields[f];
                    if (term.TermType == TermType.Variable)
                    {
                        for (int i = lhsCnt; i >= 0; i--)
                        {
                            Condition lhsCondition = node.Production.Lhs[i];
                            if (lhsCondition.ConditionType == ConditionType.Positive)
                            {
                                int pos = lhsCondition.Contains(term);
                                if (pos >= 0)
                                {
                                    Token tok2 = new_token.GetTokenUp(lhsCnt - i);
                                    newfact.Fields[f] = tok2.WME[pos];
                                    i = -1;
                                }
                            }
                        }
                    }
                    else
                    {
                        newfact.Fields[f] = term;
                    }
                }
                Activation newact = new Activation(newfact, rhsCondition.ConditionType);
                if (node.Production.InferredFacts.Contains(newact) == false)
                {
                    node.Production.InferredFacts.Add(newact);
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Binds the RHS.
 /// </summary>
 private void BindRHS(List<Activation> items)
 {
     int lhsCnt = _lhs.Count - 1;
     foreach (Activation act in items)
     {
         foreach (RightHandSideCondition condition in _rhs)
         {
             WME newfact = new WME();
             for (int f = 0; f < 3; f++)
             {
                 Term term = condition.Fields[f];
                 if (term.TermType == TermType.Variable)
                 {
                     for (int i = lhsCnt; i >= 0; i--)
                     {
                         Condition rh = _lhs[i];
                         if (rh.ConditionType == ConditionType.Positive)
                         {
                             int pos = rh.Contains(term);
                             if (pos >= 0)
                             {
                                 newfact.Fields[f] = act.InferredFact[pos];
                                 i = -1;
                             }
                         }
                     }
                 }
                 else
                 {
                     newfact.Fields[f] = term;
                 }
             }
             Activation newact = new Activation(newfact, condition.ConditionType);
             if (_inferredFacts.Contains(newact) == false)
             {
                 _inferredFacts.Add(newact);
             }
         }
     }
 }