コード例 #1
0
        /// <summary> Assert from the right side is always going to be from an Alpha node.
        ///
        /// </summary>
        /// <param name="">factInstance
        /// </param>
        /// <param name="">engine
        ///
        /// </param>
        public override void assertRight(IFact rfact, Rete engine, IWorkingMemory mem)
        {
            HashedAlphaMemoryImpl rightmem = (HashedAlphaMemoryImpl)mem.getBetaRightMemory(this);
            EqHashIndex           inx      = new EqHashIndex(NodeUtils.getRightValues(binds, rfact));

            rightmem.addPartialMatch(inx, rfact);
            // now that we've added the facts to the list, we
            // proceed with evaluating the fact
            IGenericMap <Object, Object> leftmem = (IGenericMap <Object, Object>)mem.getBetaLeftMemory(this);
            // since there may be key collisions, we iterate over the
            // values of the HashMap. If we used keySet to iterate,
            // we could encounter a ClassCastException in the case of
            // key collision.
            IEnumerator itr = leftmem.Values.GetEnumerator();

            while (itr.MoveNext())
            {
                Index linx = (Index)itr.Current;
                if (evaluate(linx.Facts, rfact))
                {
                    // now we propogate
                    propogateAssert(linx.add(rfact), engine, mem);
                }
            }
        }
コード例 #2
0
        /// <summary> Assert from the right side is always going to be from an Alpha node.
        ///
        /// </summary>
        /// <param name="">factInstance
        /// </param>
        /// <param name="">engine
        ///
        /// </param>
        public override void assertRight(IFact rfact, Rete engine, IWorkingMemory mem)
        {
            // Get the memory for the node
            HashedAlphaMemoryImpl rightmem = (HashedAlphaMemoryImpl)mem.getBetaRightMemory(this);
            EqHashIndex           inx      = new EqHashIndex(NodeUtils.getRightValues(binds, rfact));

            rightmem.addPartialMatch(inx, rfact);
            int after = rightmem.count(inx);
            IGenericMap <Object, Object> leftmem = (IGenericMap <Object, Object>)mem.getBetaLeftMemory(this);
            IEnumerator itr = leftmem.Values.GetEnumerator();

            while (itr.MoveNext())
            {
                Index linx = (Index)itr.Current;
                if (evaluate(linx.Facts, rfact))
                {
                    if (after == 1)
                    {
                        // we have to retract
                        try
                        {
                            propogateRetract(linx, engine, mem);
                        }
                        catch (RetractException e)
                        {
                            throw new AssertException("NotJion - " + e.Message);
                        }
                    }
                }
            }
        }
コード例 #3
0
        /// <summary> Assert from the right side is always going to be from an
        /// Alpha node.
        /// </summary>
        /// <param name="">factInstance
        /// </param>
        /// <param name="">engine
        ///
        /// </param>
        public override void assertRight(IFact rfact, Rete engine, IWorkingMemory mem)
        {
            HashedAlphaMemoryImpl rightmem = (HashedAlphaMemoryImpl)mem.getBetaRightMemory(this);
            EqHashIndex           inx      = new EqHashIndex(NodeUtils.getRightValues(binds, rfact));
            int after = rightmem.addPartialMatch(inx, rfact);
            IGenericMap <Object, Object> leftmem = (IGenericMap <Object, Object>)mem.getBetaLeftMemory(this);
            IEnumerator itr = leftmem.Values.GetEnumerator();

            while (itr.MoveNext())
            {
                Index linx = (Index)itr.Current;
                if (evaluate(linx.Facts, rfact))
                {
                    if (after == 1)
                    {
                        propogateAssert(linx, engine, mem);
                    }
                }
            }
        }