当前位置: 首页>>代码示例>>C#>>正文


C# Rete.nextNodeId方法代码示例

本文整理汇总了C#中Creshendo.Util.Rete.Rete.nextNodeId方法的典型用法代码示例。如果您正苦于以下问题:C# Rete.nextNodeId方法的具体用法?C# Rete.nextNodeId怎么用?C# Rete.nextNodeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Creshendo.Util.Rete.Rete的用法示例。


在下文中一共展示了Rete.nextNodeId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: testNodeId

 public void testNodeId()
 {
     Rete engine = new Rete();
     Assert.IsNotNull(engine);
     Assert.AreEqual(3, engine.peakNextNodeId());
     Assert.AreEqual(3, engine.peakNextNodeId());
     Assert.AreEqual(3, engine.peakNextNodeId());
     Console.WriteLine("we call peakNextNodeId() 3 times and it should return 3");
     Assert.AreEqual(3, engine.nextNodeId());
     Assert.AreEqual(4, engine.nextNodeId());
     Assert.AreEqual(5, engine.nextNodeId());
     int id = engine.nextNodeId();
     Assert.AreEqual(6, id);
     Console.WriteLine("if the test passes, the last id should be 6. it is " + id);
     engine.close();
 }
开发者ID:,项目名称:,代码行数:16,代码来源:

示例2: addTemplate

 /// <summary> The implementation will use either the defclass or the
 /// template name for the key. The templates are stored in
 /// a HashMap.
 /// </summary>
 public virtual void addTemplate(ITemplate temp, Rete engine, IWorkingMemory mem)
 {
     if (!deftemplates.ContainsKey(temp.Name))
     {
         // we have to set the template's module
         if (temp.ClassName != null)
         {
             deftemplates.Put(temp.Name, temp);
             deftemplates.Put(temp.ClassName, temp);
             templateCount++;
         }
         else
         {
             deftemplates.Put(temp.Name, temp);
             templateCount++;
         }
         ObjectTypeNode otn = new ObjectTypeNode(engine.nextNodeId(), temp);
         mem.RuleCompiler.addObjectTypeNode(otn);
     }
 }
开发者ID:,项目名称:,代码行数:24,代码来源:

示例3: testPropogateNoMatch

        public void testPropogateNoMatch()
        {
            Console.WriteLine("testPropogateNoMatch");
            // first create a rule engine instance
            Rete engine = new Rete();
            NotJoin nj = new NotJoin(engine.nextNodeId());
            HashedEqBNode bn2 = new HashedEqBNode(engine.nextNodeId());
            Assert.IsNotNull(nj);

            // create a defclass
            Defclass dc = new Defclass(typeof (TestBean2));
            // create deftemplate
            Deftemplate dtemp = dc.createDeftemplate("testBean2");
            Assert.IsNotNull(dtemp);
            Binding[] binds = new Binding[1];
            Binding b1 = new Binding();
            b1.LeftIndex = (0);
            b1.IsObjectVar = (false);
            b1.LeftRow = (0);
            b1.RightIndex = (0);
            b1.VarName = ("var1");
            binds[0] = b1;

            Binding[] binds2 = new Binding[1];
            Binding b2 = new Binding();
            b2.LeftIndex = (1);
            b2.IsObjectVar = (false);
            b2.LeftRow = (0);
            b2.RightIndex = (1);
            b2.VarName = ("var2");
            binds2[0] = b2;

            // set the binding
            nj.Bindings = (binds);

            bn2.Bindings = (binds2);

            // now add the second Not to the first
            try
            {
                nj.addSuccessorNode(bn2, engine, engine.WorkingMemory);
            }
            catch (AssertException e)
            {
                Console.WriteLine(e.Message);
            }

            int count = 10;
            ArrayList data = new ArrayList();
            for (int idx = 0; idx < count; idx++)
            {
                TestBean2 bean = new TestBean2();
                bean.Attr1 = ("random" + idx);
                bean.Attr2 = (101 + idx);
                short s = 10001;
                bean.Attr3 = (s);
                long l = 10101018 + idx;
                bean.Attr4 = (l);
                bean.Attr5 = (1010101);
                bean.Attr6 = (1001.1001);
                IFact fact = dtemp.createFact(bean, dc, engine.nextFactId());
                data.Add(fact);
            }

            IEnumerator itr = data.GetEnumerator();
            while (itr.MoveNext())
            {
                try
                {
                    IFact f1 = (IFact) itr.Current;
                    nj.assertLeft(new Index(new IFact[] {f1}), engine, engine.WorkingMemory);
                    nj.assertRight(f1, engine, engine.WorkingMemory);
                }
                catch (AssertException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            IGenericMap<IFact, IFact> rbmem = (IGenericMap<IFact, IFact>)engine.WorkingMemory.getBetaRightMemory(nj);
            Assert.AreEqual(count, rbmem.Count);

            IGenericMap<Object, Object> lbmem = (IGenericMap<Object, Object>) engine.WorkingMemory.getBetaLeftMemory(nj);
            Assert.AreEqual(count, lbmem.Count);

            // now check the BetaMemory has matches
            Console.WriteLine(nj.toPPString());
            IEnumerator mitr = lbmem.Values.GetEnumerator();
            while (mitr.MoveNext())
            {
                IBetaMemory btm = (IBetaMemory) mitr.Current;
                Assert.AreEqual(0, btm.matchCount());
                Console.WriteLine("match count=" + btm.matchCount() +
                                  " - " + btm.toPPString());
            }

            IGenericMap<Object, Object> lbmem2 = (IGenericMap<Object, Object>) engine.WorkingMemory.getBetaLeftMemory(bn2);
            Assert.AreEqual(count, lbmem2.Count);
            Console.WriteLine(bn2.toPPString());
            IEnumerator mitr2 = lbmem2.Values.GetEnumerator();
            engine.close();
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例4: testPropogateChange

        public void testPropogateChange()
        {
            Console.WriteLine("testPropogateChange");
            // first create a rule engine instance
            Rete engine = new Rete();
            NotJoin nj = new NotJoin(engine.nextNodeId());
            HashedEqBNode bn2 = new HashedEqBNode(engine.nextNodeId());
            Assert.IsNotNull(nj);

            // create a defclass
            Defclass dc = new Defclass(typeof (TestBean2));
            // create deftemplate
            Deftemplate dtemp = dc.createDeftemplate("testBean2");
            Assert.IsNotNull(dtemp);
            Binding[] binds = new Binding[1];
            Binding b1 = new Binding();
            b1.LeftIndex = (0);
            b1.IsObjectVar = (false);
            b1.LeftRow = (0);
            b1.RightIndex = (0);
            b1.VarName = ("var1");
            binds[0] = b1;

            Binding[] binds2 = new Binding[1];
            Binding b2 = new Binding();
            b2.LeftIndex = (1);
            b2.IsObjectVar = (false);
            b2.LeftRow = (0);
            b2.RightIndex = (1);
            b2.VarName = ("var2");
            binds2[0] = b2;

            // set the binding
            nj.Bindings = (binds);

            bn2.Bindings = (binds2);

            // now add the second Not to the first
            try
            {
                nj.addSuccessorNode(bn2, engine, engine.WorkingMemory);
            }
            catch (AssertException e)
            {
                Console.WriteLine(e.Message);
            }

            int count = 2;
            ArrayList data = new ArrayList();
            for (int idx = 0; idx < count; idx++)
            {
                TestBean2 bean = new TestBean2();
                bean.Attr1 = ("random");
                bean.Attr2 = (101 + idx);
                short s = 10001;
                bean.Attr3 = (s);
                long l = 10101018 + idx;
                bean.Attr4 = (l);
                bean.Attr5 = (1010101);
                bean.Attr6 = (1001.1001);
                IFact fact = dtemp.createFact(bean, dc, engine.nextFactId());
                data.Add(fact);
            }

            IEnumerator itr = data.GetEnumerator();
            while (itr.MoveNext())
            {
                try
                {
                    IFact f1 = (IFact) itr.Current;
                    nj.assertLeft(new Index(new IFact[] {f1}), engine, engine.WorkingMemory);
                }
                catch (AssertException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            IGenericMap<Object, Object> lbmem = (IGenericMap<Object, Object>) engine.WorkingMemory.getBetaLeftMemory(nj);
            Assert.AreEqual(count, lbmem.Count);

            IGenericMap<Object, Object> lbmem2 = (IGenericMap<Object, Object>) engine.WorkingMemory.getBetaLeftMemory(bn2);
            Assert.AreEqual(2, lbmem2.Count);

            itr = data.GetEnumerator();
            while (itr.MoveNext())
            {
                try
                {
                    IFact f1 = (IFact) itr.Current;
                    nj.assertRight(f1, engine, engine.WorkingMemory);
                }
                catch (AssertException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            IGenericMap<IFact, IFact> rbmem = (IGenericMap<IFact, IFact>)engine.WorkingMemory.getBetaRightMemory(nj);
            Assert.AreEqual(count, rbmem.Count);

            // once the facts are asserted to the right, there should be no
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例5: testAssertAndRetract

        public void testAssertAndRetract()
        {
            // first create a rule engine instance
            Rete engine = new Rete();
            NotJoin bn = new NotJoin(engine.nextNodeId());
            Assert.IsNotNull(bn);

            // create a defclass
            Defclass dc = new Defclass(typeof (TestBean2));
            // create deftemplate
            Deftemplate dtemp = dc.createDeftemplate("testBean2");
            Assert.IsNotNull(dtemp);
            Binding[] binds = new Binding[1];
            Binding b1 = new Binding();
            b1.LeftIndex = (0);
            b1.IsObjectVar = (false);
            b1.LeftRow = (0);
            b1.RightIndex = (0);
            b1.VarName = ("var1");
            binds[0] = b1;

            // set the binding
            bn.Bindings = (binds);

            int count = 10;
            ArrayList data = new ArrayList();
            for (int idx = 0; idx < count; idx++)
            {
                TestBean2 bean = new TestBean2();
                bean.Attr1 = ("random");
                bean.Attr2 = (101);
                short s = 10001;
                bean.Attr3 = (s);
                long l = 10101018;
                bean.Attr4 = (l);
                bean.Attr5 = (1010101);
                bean.Attr6 = (1001.1001);
                IFact fact = dtemp.createFact(bean, dc, engine.nextFactId());
                data.Add(fact);
            }

            IEnumerator itr = data.GetEnumerator();
            while (itr.MoveNext())
            {
                try
                {
                    IFact f1 = (IFact) itr.Current;
                    bn.assertLeft(new Index(new IFact[] {f1}), engine, engine.WorkingMemory);
                    bn.assertRight(f1, engine, engine.WorkingMemory);
                }
                catch (AssertException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            IGenericMap<IFact, IFact> rbmem = (IGenericMap<IFact, IFact>)engine.WorkingMemory.getBetaRightMemory(bn);
            Assert.AreEqual(count, rbmem.Count);

            IGenericMap<Object, Object> lbmem = (IGenericMap<Object, Object>) engine.WorkingMemory.getBetaLeftMemory(bn);
            Assert.AreEqual(count, lbmem.Count);

            int retract = 5;
            try
            {
                for (int idx = 0; idx < retract; idx++)
                {
                    IFact f2 = (IFact) data[idx];
                    bn.retractRight(f2, engine, engine.WorkingMemory);
                }
            }
            catch (RetractException e)
            {
                Console.WriteLine(e.Message);
            }

            rbmem = (IGenericMap<IFact, IFact>)engine.WorkingMemory.getBetaRightMemory(bn);
            Assert.AreEqual(retract, rbmem.Count);

            lbmem = (IGenericMap<Object, Object>) engine.WorkingMemory.getBetaLeftMemory(bn);
            Assert.AreEqual(count, lbmem.Count);

            // now check the BetaMemory has matches
            Console.WriteLine(bn.toPPString());
            IEnumerator mitr = lbmem.Values.GetEnumerator();
            while (mitr.MoveNext())
            {
                IBetaMemory btm = (IBetaMemory) mitr.Current;
                Console.WriteLine("match count=" + btm.matchCount() +
                                  " - " + btm.toPPString());
            }
            engine.close();
        }
开发者ID:,项目名称:,代码行数:92,代码来源:

示例6: testCreateNode2

        public void testCreateNode2()
        {
            // first create a rule engine instance
            Rete engine = new Rete();
            NotJoin bn = new NotJoin(engine.nextNodeId());
            Assert.IsNotNull(bn);

            // create a defclass
            Defclass dc = new Defclass(typeof (TestBean2));
            // create deftemplate
            Deftemplate dtemp = dc.createDeftemplate("testBean2");
            Assert.IsNotNull(dtemp);
            Binding[] binds = new Binding[1];
            Binding b1 = new Binding();
            b1.LeftIndex = (0);
            b1.IsObjectVar = (false);
            b1.LeftRow = (0);
            b1.RightIndex = (0);
            b1.VarName = ("var1");
            binds[0] = b1;

            // set the binding
            bn.Bindings = (binds);
            engine.close();
        }
开发者ID:,项目名称:,代码行数:25,代码来源:

示例7: testCreateNode

 public void testCreateNode()
 {
     Rete engine = new Rete();
     NotJoin bn = new NotJoin(engine.nextNodeId());
     Assert.IsNotNull(bn);
     engine.close();
 }
开发者ID:,项目名称:,代码行数:7,代码来源:

示例8: testAssertRightMultiple

        public void testAssertRightMultiple()
        {
            // first create a rule engine instance
            Rete engine = new Rete();
            NotJoin bn = new NotJoin(engine.nextNodeId());
            Assert.IsNotNull(bn);

            // create a defclass
            Defclass dc = new Defclass(typeof (TestBean2));
            // create deftemplate
            Deftemplate dtemp = dc.createDeftemplate("testBean2");
            Assert.IsNotNull(dtemp);
            Binding[] binds = new Binding[1];
            Binding b1 = new Binding();
            b1.LeftIndex = (0);
            b1.IsObjectVar = (false);
            b1.LeftRow = (0);
            b1.RightIndex = (0);
            b1.VarName = ("var1");
            binds[0] = b1;

            // set the binding
            bn.Bindings = (binds);

            int count = 10;
            ArrayList data = new ArrayList();
            for (int idx = 0; idx < count; idx++)
            {
                TestBean2 bean = new TestBean2();
                bean.Attr1 = ("random" + (idx + 1));
                bean.Attr2 = (101);
                short s = 10001;
                bean.Attr3 = (s);
                long l = 10101018;
                bean.Attr4 = (l);
                bean.Attr5 = (1010101);
                bean.Attr6 = (1001.1001);
                IFact fact = dtemp.createFact(bean, dc, engine.nextFactId());
                data.Add(fact);
            }
            IEnumerator itr = data.GetEnumerator();
            while (itr.MoveNext())
            {
                try
                {
                    IFact f1 = (IFact) itr.Current;
                    bn.assertRight(f1, engine, engine.WorkingMemory);
                }
                catch (AssertException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            IGenericMap<IFact, IFact> bmem = (IGenericMap<IFact, IFact>)engine.WorkingMemory.getBetaRightMemory(bn);
            Assert.AreEqual(count, bmem.Count);
            engine.close();
        }
开发者ID:,项目名称:,代码行数:57,代码来源:

示例9: testAssertLeftOne

        public void testAssertLeftOne()
        {
            // first create a rule engine instance
            Rete engine = new Rete();
            NotJoin bn = new NotJoin(engine.nextNodeId());
            Assert.IsNotNull(bn);

            // create a defclass
            Defclass dc = new Defclass(typeof (TestBean2));
            // create deftemplate
            Deftemplate dtemp = dc.createDeftemplate("testBean2");
            Assert.IsNotNull(dtemp);
            Binding[] binds = new Binding[1];
            Binding b1 = new Binding();
            b1.LeftIndex = (0);
            b1.IsObjectVar = (false);
            b1.LeftRow = (0);
            b1.RightIndex = (0);
            b1.VarName = ("var1");
            binds[0] = b1;

            // set the binding
            bn.Bindings = (binds);

            TestBean2 bean = new TestBean2();
            bean.Attr1 = ("random1");
            bean.Attr2 = (101);
            short s = 10001;
            bean.Attr3 = (s);
            long l = 10101018;
            bean.Attr4 = (l);
            bean.Attr5 = (1010101);
            bean.Attr6 = (1001.1001);
            IFact f1 = dtemp.createFact(bean, dc, engine.nextFactId());
            try
            {
                bn.assertLeft(new Index(new IFact[] {f1}), engine, engine.WorkingMemory);
                IGenericMap<Object, Object> bmem = (IGenericMap<Object, Object>) engine.WorkingMemory.getBetaLeftMemory(bn);
                Assert.AreEqual(1, bmem.Count);
            }
            catch (AssertException e)
            {
                Console.WriteLine(e.Message);
            }
            engine.close();
        }
开发者ID:,项目名称:,代码行数:46,代码来源:


注:本文中的Creshendo.Util.Rete.Rete.nextNodeId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。