Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        //[System.Diagnostics.DebuggerHidden]
        public override object Clone()
        {
            ActionExpression f = (ActionExpression)base.Clone();

            f.equation    = this.equation;
            f.operatingId = this.operatingId;
            f.evaluator   = this.evaluator;
            return(f);
        }
Exemplo n.º 2
0
        private static void IndividualFactTest()
        {
            DateTime end;
            DateTime start;
            TimeSpan diff;
            Xml x;
            int total;

            ROM rom = new ROM();

            //set up out facts
            Fact F1 = new Fact("F1", 1, new Naked("1", typeof(double)), typeof(double));
            Fact F2 = new Fact("F2", 1, new Naked("1", typeof(double)), typeof(double));
            Fact F3 = new Fact("F3", 1, new Naked(null, typeof(double)), typeof(double));
            rom.AddEvidence(F1);
            rom.AddEvidence(F2);
            rom.AddEvidence(F3);

            //set up our assignments
            ActionExpression A1 = new ActionExpression("1", "F1", "2", 2);
            ActionExpression A2 = new ActionExpression("2", "F2", "2", 2);
            rom.AddEvidence(A1);
            rom.AddEvidence(A2);

            List<EvidenceSpecifier> list = new List<EvidenceSpecifier>();
            list.Add(new EvidenceSpecifier(true, "1"));
            list.Add(new EvidenceSpecifier(true, "2"));

            //create a rule
            Rule R1 = new Rule("R1", "1==1", list, 500, true);

            rom.AddEvidence(R1);
            rom.Evaluate();

            Console.WriteLine("Starting Test:" + DateTime.Now);
            total = 1000;
            start = DateTime.Now;
            for (int counter = 0; counter < total; counter++)
            {
                //cause rules to evaluate
                rom.Evaluate();
            }
            end = DateTime.Now;
            diff = end - start;
            Console.WriteLine("Total ms: " + diff.TotalMilliseconds);
            Console.WriteLine("milliseconds per rule: " + (diff.TotalMilliseconds / (total * 8d))); //eight rules per run
        }