Beispiel #1
0
        /// <summary>
        /// Save facts of the current working memory. Current implications, facts and queries
        /// remain unchanged.
        /// </summary>
        /// <remarks>
        /// The adapter will be disposed at the end of the method's execution.
        /// </remarks>
        /// <param name="adapter">The Adapter used to save the fact base.</param>
        public void SaveFacts(IFactBaseAdapter adapter)
        {
            CheckInitialized();
            if (HasLogListener)
            {
                ForceDispatchLog("NxBRE Inference Engine Facts Saving Started, using adapter " + adapter.GetType().FullName,
                                 LogEventImpl.INFO);
            }
            using (adapter) {
                // header
                adapter.Direction = Direction;
                adapter.Label     = Label;

                // facts
                ArrayList facts = new ArrayList();
                foreach (Fact fact in WM.FB)
                {
                    facts.Add(fact);
                }
                adapter.Facts = facts;
            }             //end: using adapter

            if (HasLogListener)
            {
                ForceDispatchLog("NxBRE Inference Engine Facts Saving Finished", LogEventImpl.INFO);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Load facts in the current working memory. Current implications, facts and queries
        /// remain unchanged.
        /// </summary>
        /// <remarks>
        /// The adapter will be disposed at the end of the method's execution.
        /// </remarks>
        /// <param name="adapter">The Adapter used to read the fact base.</param>
        public void LoadFacts(IFactBaseAdapter adapter)
        {
            CheckInitialized();
            if (HasLogListener)
            {
                ForceDispatchLog("NxBRE Inference Engine Facts Loading Started, using adapter " + adapter.GetType().FullName,
                                 LogEventImpl.INFO);
            }

            using (adapter) {
                // sets the eventual Binder
                if (Binder != null)
                {
                    adapter.Binder = Binder;
                }

                // load facts
                int initialFactsCount = WM.FB.Count;
                foreach (Fact fact in adapter.Facts)
                {
                    Assert(fact);
                }
                if (HasLogListener)
                {
                    ForceDispatchLog("Added " + (WM.FB.Count - initialFactsCount) + " new Facts", LogEventImpl.DEBUG);
                }
            }             //end: using adapter
            if (HasLogListener)
            {
                ForceDispatchLog("NxBRE Inference Engine Facts Loading Finished", LogEventImpl.INFO);
            }
        }
Beispiel #3
0
        public static void ExportResults(IList <IList <Fact> > results, IFactBaseAdapter factBaseAdapter, string factBaseLabel)
        {
            if (factBaseAdapter == null)
            {
                throw new ArgumentNullException("A non-null fact base adapter must be provided");
            }
            if (factBaseLabel == null)
            {
                throw new ArgumentNullException("A non-null fact base label must be provided");
            }

            var flattenedResults = new List <Fact>();

            foreach (IList <Fact> row in results)
            {
                flattenedResults.AddRange(row);
            }

            using (factBaseAdapter) {
                factBaseAdapter.Direction = String.Empty;
                factBaseAdapter.Label     = factBaseLabel;
                factBaseAdapter.Facts     = flattenedResults;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Save facts of the current working memory. Current implications, facts and queries
        /// remain unchanged.
        /// </summary>
        /// <remarks>
        /// The adapter will be disposed at the end of the method's execution.
        /// </remarks>
        /// <param name="adapter">The Adapter used to save the fact base.</param>
        public void SaveFacts(IFactBaseAdapter adapter)
        {
            CheckInitialized();

            if (Logger.IsInferenceEngineInformation) Logger.InferenceEngineSource.TraceEvent(TraceEventType.Information, 0, "NxBRE Inference Engine Facts Saving Started, using adapter " + adapter.GetType().FullName);

            using(adapter) {
                // header
                adapter.Direction = Direction;
                adapter.Label = Label;

                // facts
                IList<Fact> facts = new List<Fact>();
                foreach(Fact fact in WM.FB)	facts.Add(fact);
                adapter.Facts = facts;
            } //end: using adapter

            if (Logger.IsInferenceEngineInformation) Logger.InferenceEngineSource.TraceEvent(TraceEventType.Information, 0, "NxBRE Inference Engine Facts Saving Finished");
        }
Beispiel #5
0
        /// <summary>
        /// Load facts in the current working memory. Current implications, facts and queries
        /// remain unchanged.
        /// </summary>
        /// <remarks>
        /// The adapter will be disposed at the end of the method's execution.
        /// </remarks>
        /// <param name="adapter">The Adapter used to read the fact base.</param>
        public void LoadFacts(IFactBaseAdapter adapter)
        {
            CheckInitialized();

            if (Logger.IsInferenceEngineInformation) Logger.InferenceEngineSource.TraceEvent(TraceEventType.Information, 0, "NxBRE Inference Engine Facts Loading Started, using adapter " + adapter.GetType().FullName);

            using(adapter) {
                // sets the eventual Binder
                if (Binder != null) adapter.Binder = Binder;

                // load facts
                int initialFactsCount = WM.FB.Count;
                foreach(Fact fact in adapter.Facts) Assert(fact);
                if (Logger.IsInferenceEngineVerbose) Logger.InferenceEngineSource.TraceEvent(TraceEventType.Verbose, 0, "Added " + (WM.FB.Count - initialFactsCount) + " new Facts");

            } //end: using adapter

            if (Logger.IsInferenceEngineInformation) Logger.InferenceEngineSource.TraceEvent(TraceEventType.Information, 0, "NxBRE Inference Engine Facts Loading Finished");
        }
Beispiel #6
0
 public static void ExportResults(IList <IList <Fact> > results, IFactBaseAdapter factBaseAdapter)
 {
     ExportResults(results, factBaseAdapter, String.Empty);
 }
Beispiel #7
0
        /// <summary>
        /// Save facts of the current working memory. Current implications, facts and queries
        /// remain unchanged.
        /// </summary>
        /// <remarks>
        /// The adapter will be disposed at the end of the method's execution.
        /// </remarks>
        /// <param name="adapter">The Adapter used to save the fact base.</param>
        public void SaveFacts(IFactBaseAdapter adapter)
        {
            CheckInitialized();
            if (HasLogListener) ForceDispatchLog("NxBRE Inference Engine Facts Saving Started, using adapter " + adapter.GetType().FullName,
                                                                            LogEventImpl.INFO);
            using(adapter) {
                // header
                adapter.Direction = Direction;
                adapter.Label = Label;

                // facts
                ArrayList facts = new ArrayList();
                foreach(Fact fact in WM.FB)	facts.Add(fact);
                adapter.Facts = facts;
            } //end: using adapter

            if (HasLogListener) ForceDispatchLog("NxBRE Inference Engine Facts Saving Finished", LogEventImpl.INFO);
        }
Beispiel #8
0
        /// <summary>
        /// Load facts in the current working memory. Current implications, facts and queries
        /// remain unchanged.
        /// </summary>
        /// <remarks>
        /// The adapter will be disposed at the end of the method's execution.
        /// </remarks>
        /// <param name="adapter">The Adapter used to read the fact base.</param>
        public void LoadFacts(IFactBaseAdapter adapter)
        {
            CheckInitialized();
            if (HasLogListener) ForceDispatchLog("NxBRE Inference Engine Facts Loading Started, using adapter " + adapter.GetType().FullName,
                                                                            LogEventImpl.INFO);

            using(adapter) {
                // sets the eventual Binder
                if (Binder != null) adapter.Binder = Binder;

                // load facts
                int initialFactsCount = WM.FB.Count;
                foreach(Fact fact in adapter.Facts) Assert(fact);
                if (HasLogListener) ForceDispatchLog("Added " + (WM.FB.Count - initialFactsCount) + " new Facts", LogEventImpl.DEBUG);

            } //end: using adapter
            if (HasLogListener) ForceDispatchLog("NxBRE Inference Engine Facts Loading Finished", LogEventImpl.INFO);
        }