Ejemplo n.º 1
0
        public override void PrepareInitialization()
        {
            lockStrategy.AcquireUniqueLock();

            WorkingType    = WorkingMemoryTypes.Global;
            globalFactBase = new FactBase();
        }
Ejemplo n.º 2
0
        public override void PrepareInitialization()
        {
            lockStrategy.AcquireUniqueLock();

            WorkingType = WorkingMemoryTypes.Global;
            globalFactBase = new FactBase();
        }
Ejemplo n.º 3
0
 public override void PrepareInitialization()
 {
     WorkingType     = WorkingMemoryTypes.Global;
     globalFactBase  = new FactBase();
     WorkingFactBase = globalFactBase;
 }
Ejemplo n.º 4
0
		public override void PrepareInitialization() {
			type = WorkingMemoryTypes.Global;
			globalFactBase = new FactBase();
			workingFactBase = globalFactBase;
		}
Ejemplo n.º 5
0
        public void FactBaseAssertRetract()
        {
            FactBase fb = new FactBase();

            Assert.IsTrue(fb.Assert(new Fact("spending",
                            new Individual("Peter Miller"),
                            new Individual("min(5000,EUR)"),
                            new Individual("previous year"))), "Assert 'P.Miller Spending'");

            Assert.IsTrue(fb.Assert(new Fact("JQD Spending",
                               "spending",
                            new Individual("John Q.Clone Doe"),
                            new Individual("min(7000,EUR)"),
                            new Individual("previous year"))), "Assert 'JQD Spending'");

            Assert.IsNotNull(fb.GetFact("JQD Spending"), "Exist 'JQD Spending'");

            Assert.IsFalse(fb.Assert(fact3bis), "Assert fact3bis");
            Assert.IsTrue(fb.Assert(factX), "Assert factX");
            fb.Retract(fb.GetFact("JQD Spending"));
            Assert.IsNull(fb.GetFact("JQD Spending"), "Retract 'JQD Spending'");
        }
Ejemplo n.º 6
0
        public void FactBaseAssertModify()
        {
            FactBase fb = new FactBase();

            Fact spendingPM1 = new Fact("Spending of Peter Miller",
                                        "spending",
                                               new Individual("Peter Miller"),
                                               new Individual("min(5000,EUR)"),
                                               new Individual("previous year"));

            Assert.IsTrue(fb.Assert(spendingPM1), "Assert 'P.Miller Spending' v1");
            Assert.IsTrue(fb.Exists(spendingPM1), "Exists 'P.Miller Spending' v1");

            Fact spendingJQD = new Fact("Spending of John Q. Doe",
                                        "spending",
                                            new Individual("John Q.Clone Doe"),
                                            new Individual("min(7000,EUR)"),
                                            new Individual("previous year"));

            Assert.IsTrue(fb.Assert(spendingJQD), "Assert 'JQD Spending'");

            Fact spendingPM2 = new Fact("spending",
                                               new Individual("Peter Miller"),
                                               new Individual("min(9999,EUR)"),
                                               new Individual("previous year"));

            Assert.IsTrue(fb.Modify(spendingPM1, spendingPM2), "Modify 'P.Miller Spending' v1 to v2");
            Assert.IsNotNull(fb.GetFact(spendingPM1.Label), "(1) Label has been maintained");
            Assert.AreEqual(2, fb.Count, "(1) FactBase size");
            Assert.IsFalse(fb.Exists(spendingPM1), "(1) Not Exists 'P.Miller Spending' v1");
            Assert.IsTrue(fb.Exists(spendingPM2), "(1) Exists 'P.Miller Spending' v2");
            Assert.IsTrue(fb.Exists(spendingJQD), "(1) Exists 'JQD Spending'");

            Assert.IsFalse(fb.Modify(spendingPM1, spendingPM2), "Can not modify an inexistant fact");
            Assert.AreEqual(2, fb.Count, "(2) FactBase size");
            Assert.IsFalse(fb.Exists(spendingPM1), "(2) Not Exists 'P.Miller Spending' v1");
            Assert.IsTrue(fb.Exists(spendingPM2), "(2) Exists 'P.Miller Spending' v2");
            Assert.IsTrue(fb.Exists(spendingJQD), "(2) Exists 'JQD Spending'");

            Assert.IsTrue(fb.Modify(spendingPM2, spendingPM2), "Can modify a fact to itself");
            Assert.AreEqual(2, fb.Count, "(3) FactBase size");
            Assert.IsFalse(fb.Exists(spendingPM1), "(3) Not Exists 'P.Miller Spending' v1");
            Assert.IsTrue(fb.Exists(spendingPM2), "(3) Exists 'P.Miller Spending' v2");
            Assert.IsTrue(fb.Exists(spendingJQD), "(3) Exists 'JQD Spending'");

            Assert.IsTrue(fb.Modify(spendingJQD, spendingPM2), "Modify 'JQD Spending' to 'P.Miller Spending' v2");
            Assert.IsNotNull(fb.GetFact(spendingJQD.Label), "(4) Label has been maintained");
            Assert.AreEqual(1, fb.Count, "(4) FactBase size");
            Assert.IsFalse(fb.Exists(spendingPM1), "(4) Not Exists 'P.Miller Spending' v1");
            Assert.IsTrue(fb.Exists(spendingPM2), "(4) Exists 'P.Miller Spending' v2");
            Assert.IsFalse(fb.Exists(spendingJQD), "(4) Not Exists 'JQD Spending'");
        }
Ejemplo n.º 7
0
		///<summary>Clones the fact base. Except for facts collections, all other internal
		/// references point to the same objects as the original KB.</summary>
		public object Clone() {
			FactBase newfb = new FactBase();
			
			newfb.factList = (Hashtable)factList.Clone();
			newfb.atomList = (Hashtable)atomList.Clone();
			newfb.matchedFactDataSet = matchedFactDataSet.Copy();
			
			return newfb;
		}