Пример #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)
        {
            // Get the memory for the node
            HashedNeqAlphaMemory rightmem = (HashedNeqAlphaMemory)mem.getBetaRightMemory(this);
            NotEqHashIndex       inx      = new NotEqHashIndex(NodeUtils.getRightBindValues(binds, rfact));

            rightmem.addPartialMatch(inx, rfact);
            // now that we've added the facts to the list, we
            // proceed with evaluating the fact
            // else we compare the fact to all facts in the left
            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
            HashedNeqAlphaMemory rightmem = (HashedNeqAlphaMemory)mem.getBetaRightMemory(this);
            NotEqHashIndex       inx      = new NotEqHashIndex(NodeUtils.getRightBindValues(binds, rfact));

            rightmem.addPartialMatch(inx, rfact);
            bool zm = rightmem.zeroMatch(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 (!zm)
                    {
                        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)
        {
            HashedNeqAlphaMemory rightmem = (HashedNeqAlphaMemory)mem.getBetaRightMemory(this);
            NotEqHashIndex       inx      = new NotEqHashIndex(NodeUtils.getRightBindValues(binds, rfact));

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

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