Example #1
0
        public void PerformProcess(IBinder binder)
        {
            // generate dummy business objects
            IDictionary businessObjects = DummyData.GetInstance().GetBusinessObjects(nbDecaCustomers);


            // instantiate an inference engine, bind my data and process the rules
            IInferenceEngine ie = new IEImpl(binder);

            ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleBaseFile, System.IO.FileAccess.Read));
            ie.Process(businessObjects);

            // processing is done, let's analyze the results
            IList <IList <Fact> > qrs = ie.RunQuery("Fraudulent Customers");

            Console.WriteLine("\nDetected {0} fraudulent customers.", qrs.Count);
            if (qrs.Count != 2 * nbDecaCustomers)
            {
                Console.WriteLine("\nError! " + 2 * nbDecaCustomers + " was expected.");
            }

            // check if the customer objects have been flagged correctly
            int flaggedCount = 0;

            foreach (Customer customer in (ArrayList)businessObjects["CUSTOMERS"])
            {
                if (customer.Fraudulent)
                {
                    flaggedCount++;
                }
            }

            if (flaggedCount != 2 * nbDecaCustomers)
            {
                throw new Exception("\nError! " + 2 * nbDecaCustomers + " flagged Customer objects were expected.\n");
            }
            else
            {
                Console.WriteLine("\nCustomer objects were correctly flagged\n");
            }
        }
Example #2
0
        public void Run()
        {
            // prepare some dummy data
            Hashtable businessObjects = new Hashtable();
            ArrayList callData        = DummyData.GetInstance().GetBusinessObjects(nbDodecaCalls);

            businessObjects.Add("CALLSDATA", callData);

            // process this data
            Console.WriteLine("Using RuleBase: {0}", ie.Label);
            long iniTime = DateTime.Now.Ticks;

            ie.Process(businessObjects);
            Console.WriteLine("{0} Calls processed in: {1} milliseconds",
                              12 * nbDodecaCalls,
                              (int)(DateTime.Now.Ticks - iniTime) / 10000);

            // ensure the engine is rating correctly
            foreach (CallData cd in callData)
            {
                cd.CheckValidity();
            }
        }
Example #3
0
 public static DummyData GetInstance()
 {
     if (dd == null) dd = new DummyData();
     return dd;
 }