public Stresser(int stresserID, MainClass mc, IInferenceEngine ie) { this.stresserID = stresserID; this.mc = mc; this.ie = ie; this.bumps = 0; }
public void SetUp() { _initialDataProviderMock = MockRepository.GenerateMock <IDataProvider>(); _knowledgeManagerMock = MockRepository.GenerateMock <IKnowledgeBaseManager>(); _inferenceEngineMock = MockRepository.GenerateMock <IInferenceEngine>(); _fuzzyEngineMock = MockRepository.GenerateMock <IFuzzyEngine>(); }
public CachedEngine(string configurationFolder, EngineConfiguration engineConfiguration) { this.configurationFolder = configurationFolder; this.engineConfiguration = engineConfiguration; // instantiate the IInferenceEngine engine = new IEImpl(ThreadingModelTypes.MultiHotSwap); }
public void DestroyIE() { ie = null; if (Logger.IsInferenceEngineVerbose) { Logger.InferenceEngineSource.TraceEvent(TraceEventType.Verbose, 0, "DestroyIE()"); } }
public RatingEngine(int verbosityLevel, int nbDodecaCalls, string ruleBaseFile) { this.nbDodecaCalls = nbDodecaCalls; ie = new IEImpl(CSharpBinderFactory.LoadFromFile("NxBRE.Examples.TelcoRatingBinder", ruleBaseFile + ".ccb")); if (verbosityLevel >= 1) ie.NewFactHandler += new NewFactEvent(HandleNewFactEvent); ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleBaseFile, System.IO.FileAccess.Read)); }
protected virtual void NewIEImpl(IBinder bob) { if (bob != null) { ie = new IEImpl(bob); } else { ie = new IEImpl(); } }
public FuzzyExpert( IDataProvider dataProvider, IKnowledgeBaseManager knowledgeBaseManager, IInferenceEngine inferenceEngine, IFuzzyEngine fuzzyEngine) { _initialDataProvider = dataProvider ?? throw new ArgumentNullException(nameof(dataProvider)); _knowledgeManager = knowledgeBaseManager ?? throw new ArgumentNullException(nameof(knowledgeBaseManager)); _inferenceEngine = inferenceEngine ?? throw new ArgumentNullException(nameof(inferenceEngine)); _fuzzyEngine = fuzzyEngine ?? throw new ArgumentNullException(nameof(fuzzyEngine)); }
public RatingEngine(int verbosityLevel, int nbDodecaCalls, string ruleBaseFile) { this.nbDodecaCalls = nbDodecaCalls; ie = new IEImpl(CSharpBinderFactory.LoadFromFile("NxBRE.Examples.TelcoRatingBinder", ruleBaseFile + ".ccb")); if (verbosityLevel >= 1) { ie.NewFactHandler += new NewFactEvent(HandleNewFactEvent); } ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleBaseFile, System.IO.FileAccess.Read)); }
public static void Main(string[] args) { HOT_SWAP = Boolean.Parse(args[0]); binder = Boolean.Parse(args[1]); if (args.Length > 2) csharpBinder = Boolean.Parse(args[2]); MAIN_IE = new IEImpl((HOT_SWAP)?ThreadingModelTypes.MultiHotSwap:ThreadingModelTypes.Multi); SECOND_IE = new IEImpl((HOT_SWAP)?ThreadingModelTypes.MultiHotSwap:ThreadingModelTypes.Single); MainClass mc = new MainClass(); InitMainEngine(); SECOND_IE.LoadRuleBase(new RuleML09NafDatalogAdapter(XMLFOLDER + "subtract.ruleml", System.IO.FileAccess.Read)); mc.RunTests(); }
/// <summary> /// Adds an Inference Engine to the Triple Store /// </summary> /// <param name="reasoner">Reasoner to add</param> public void AddInferenceEngine(IInferenceEngine reasoner) { this._reasoners.Add(reasoner); //Apply Inference to all existing Graphs if (this._graphs.Count > 0) { lock (this._graphs) { //Have to do a ToList() in case someone else inserts a Graph //Which ApplyInference may do if the Inference information is stored in a special Graph foreach (IGraph g in this._graphs.ToList()) { this.ApplyInference(g); } } } }
public static void Main(string[] args) { HOT_SWAP = Boolean.Parse(args[0]); binder = Boolean.Parse(args[1]); if (args.Length > 2) { csharpBinder = Boolean.Parse(args[2]); } MAIN_IE = new IEImpl((HOT_SWAP)?ThreadingModelTypes.MultiHotSwap:ThreadingModelTypes.Multi); SECOND_IE = new IEImpl((HOT_SWAP)?ThreadingModelTypes.MultiHotSwap:ThreadingModelTypes.Single); MainClass mc = new MainClass(); InitMainEngine(); SECOND_IE.LoadRuleBase(new RuleML09NafDatalogAdapter(XMLFOLDER + "subtract.ruleml", System.IO.FileAccess.Read)); mc.RunTests(); }
private void RunTestBinderEvents(IInferenceEngine ie) { ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleFilesFolder + "events-test.ruleml", FileAccess.Read)); Hashtable bo = new Hashtable(); bo.Add("ASSERTED", new ArrayList()); bo.Add("RETRACTED", new ArrayList()); bo.Add("MODIFIED", new ArrayList()); ie.Process(bo); Assert.AreEqual(2, ((ArrayList)bo["ASSERTED"]).Count, "Count Asserted"); Assert.IsTrue(Misc.IListToString((ArrayList)bo["ASSERTED"]).Contains("toAssert{whatever}"), "Asserted Right"); Assert.AreEqual(1, ((ArrayList)bo["RETRACTED"]).Count, "Count Retracted"); Assert.AreEqual("toRetract{whatever}", ((ArrayList)bo["RETRACTED"])[0].ToString(), "Retracted Right"); Assert.AreEqual(2, ((ArrayList)bo["MODIFIED"]).Count, "Count Modified"); Assert.AreEqual("toModify{whatever}", ((ArrayList)bo["MODIFIED"])[0].ToString(), "Modified From Right"); Assert.AreEqual("toModify{done}", ((ArrayList)bo["MODIFIED"])[1].ToString(), "Modified To Right"); }
/// <summary> /// Removes an Inference Engine from the Triple Store /// </summary> /// <param name="reasoner">Reasoner to remove</param> public void RemoveInferenceEngine(IInferenceEngine reasoner) { this._reasoners.Remove(reasoner); }
/// <summary> /// Creates a new Reasoner Graph which is a wrapper around an existing Graph with a reasoner applied and the resulting Triples materialised /// </summary> /// <param name="g">Graph</param> /// <param name="reasoner">Reasoner</param> public ReasonerGraph(IGraph g, IInferenceEngine reasoner) { this._baseGraph = g; this._reasoners.Add(reasoner); this.Initialise(); }
protected virtual void NewIEImpl(IBinder bob) { if (bob != null) ie = new IEImpl(bob); else ie = new IEImpl(); }
public void DestroyIE() { ie = null; if (Logger.IsInferenceEngineVerbose) Logger.InferenceEngineSource.TraceEvent(TraceEventType.Verbose, 0, "DestroyIE()"); }
/// <summary> /// Instantiates a new IEFacade that wraps an instance of the Inference Engine. /// </summary> /// <param name="ie">The Inference Engine the new facade must encapsulate.</param> public IEFacade(IInferenceEngine ie) { this.ie = ie; }
private void RunTestBinderEvents(IInferenceEngine ie) { ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleFilesFolder + "events-test.ruleml", FileAccess.Read)); //ie.LogHandlers += new DispatchLog(ShowAllLogs); Hashtable bo = new Hashtable(); bo.Add("ASSERTED", new ArrayList()); bo.Add("RETRACTED", new ArrayList()); bo.Add("MODIFIED", new ArrayList()); ie.Process(bo); Assert.AreEqual(1, ((ArrayList)bo["ASSERTED"]).Count, "Count Asserted"); Assert.AreEqual("toAssert{whatever}", ((ArrayList)bo["ASSERTED"])[0].ToString(), "Asserted Right"); Assert.AreEqual(1, ((ArrayList)bo["RETRACTED"]).Count, "Count Retracted"); Assert.AreEqual("toRetract{whatever}", ((ArrayList)bo["RETRACTED"])[0].ToString(), "Retracted Right"); Assert.AreEqual(2, ((ArrayList)bo["MODIFIED"]).Count, "Count Modified"); Assert.AreEqual("toModify{whatever}", ((ArrayList)bo["MODIFIED"])[0].ToString(), "Modified From Right"); Assert.AreEqual("toModify{done}", ((ArrayList)bo["MODIFIED"])[1].ToString(), "Modified To Right"); }
public void LoadRuleBase(MainForm mf, string uri, bool onlyFacts) { IBinder binder = null; // give priority to custom compiled binders if (File.Exists(uri + ".ccb")) { up.lastBinderClassName = mf.PromptForString("C# Custom Binder - " + uri + ".ccb", "Enter the fully qualified name of the binder class:", up.lastBinderClassName); binder = CSharpBinderFactory.LoadFromFile(up.lastBinderClassName, uri + ".ccb"); } else if (File.Exists(uri + ".vcb")) { up.lastBinderClassName = mf.PromptForString("VB.NET Custom Binder - " + uri + ".vcb", "Enter the fully qualified name of the binder class:", up.lastBinderClassName); binder = VisualBasicBinderFactory.LoadFromFile(up.lastBinderClassName, uri + ".vcb"); } else if (File.Exists(uri + ".xbre")) { bool isBeforeAfter = mf.AskYesNoQuestion("Flow Engine Binder - " + uri + ".xbre", uri + ".xbre\n\nIs this binder running in Before/After mode ?\n\n(No would mean that it runs in Control Process mode)"); binder = new FlowEngineBinder(uri + ".xbre", isBeforeAfter?BindingTypes.BeforeAfter:BindingTypes.Control); } if (!onlyFacts) { ie = new IEImpl(binder); } switch (Path.GetExtension(uri).ToLower()) { case ".ruleml": try { if (onlyFacts) { ie.LoadFacts(new RuleML09NafDatalogAdapter(uri, FileAccess.Read)); } else { ie.LoadRuleBase(new RuleML09NafDatalogAdapter(uri, FileAccess.Read)); } } catch (Exception firstAttemptException) { try { if (onlyFacts) { ie.LoadFacts(new RuleML086NafDatalogAdapter(uri, FileAccess.Read)); } else { ie.LoadRuleBase(new RuleML086NafDatalogAdapter(uri, FileAccess.Read)); } } catch (Exception) { try { if (onlyFacts) { ie.LoadFacts(new RuleML086DatalogAdapter(uri, FileAccess.Read)); } else { ie.LoadRuleBase(new RuleML086DatalogAdapter(uri, FileAccess.Read)); } } catch (Exception) { try { if (onlyFacts) { ie.LoadFacts(new RuleML08DatalogAdapter(uri, FileAccess.Read)); } else { ie.LoadRuleBase(new RuleML08DatalogAdapter(uri, FileAccess.Read)); } } catch (Exception) { // the fall-back policy failed, hence throw the original exception throw firstAttemptException; } } } } break; case ".hrf": if (onlyFacts) { ie.LoadFacts(new HRF086Adapter(uri, FileAccess.Read)); } else { ie.LoadRuleBase(new HRF086Adapter(uri, FileAccess.Read)); } break; case ".vdx": string[] selectedPages = mf.PromptForVisioPageNameSelection(Visio2003Adapter.GetPageNames(uri)); if (selectedPages != null) { if (onlyFacts) { ie.LoadFacts(new Visio2003Adapter(uri, FileAccess.Read, selectedPages)); } else { ie.LoadRuleBase(new Visio2003Adapter(uri, FileAccess.Read, (DialogResult.Yes == MessageBox.Show(mf, "Is your Visio rule base using strict syntax?", "Visio strictness", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)), selectedPages)); } } break; default: throw new Exception(Path.GetExtension(uri) + " is an unknown extension."); } }
public void LoadRuleBase(MainForm mf, string uri, bool onlyFacts) { IBinder binder = null; // give priority to custom compiled binders if (File.Exists(uri + ".ccb")) { up.lastBinderClassName = mf.PromptForString("C# Custom Binder - " + uri + ".ccb", "Enter the fully qualified name of the binder class:", up.lastBinderClassName); binder = CSharpBinderFactory.LoadFromFile(up.lastBinderClassName, uri + ".ccb"); } else if (File.Exists(uri + ".vcb")) { up.lastBinderClassName = mf.PromptForString("VB.NET Custom Binder - " + uri + ".vcb", "Enter the fully qualified name of the binder class:", up.lastBinderClassName); binder = VisualBasicBinderFactory.LoadFromFile(up.lastBinderClassName, uri + ".vcb"); } else if (File.Exists(uri + ".xbre")) { bool isBeforeAfter = mf.AskYesNoQuestion("Flow Engine Binder - " + uri + ".xbre", uri + ".xbre\n\nIs this binder running in Before/After mode ?\n\n(No would mean that it runs in Control Process mode)"); binder = new FlowEngineBinder(uri + ".xbre", isBeforeAfter?BindingTypes.BeforeAfter:BindingTypes.Control); } if (!onlyFacts) ie = new IEImpl(binder); switch(Path.GetExtension(uri).ToLower()) { case ".ruleml": try { if (onlyFacts) ie.LoadFacts(new RuleML09NafDatalogAdapter(uri, FileAccess.Read)); else ie.LoadRuleBase(new RuleML09NafDatalogAdapter(uri, FileAccess.Read)); } catch(Exception firstAttemptException) { try { if (onlyFacts) ie.LoadFacts(new RuleML086NafDatalogAdapter(uri, FileAccess.Read)); else ie.LoadRuleBase(new RuleML086NafDatalogAdapter(uri, FileAccess.Read)); } catch(Exception) { try { if (onlyFacts) ie.LoadFacts(new RuleML086DatalogAdapter(uri, FileAccess.Read)); else ie.LoadRuleBase(new RuleML086DatalogAdapter(uri, FileAccess.Read)); } catch(Exception) { try { if (onlyFacts) ie.LoadFacts(new RuleML08DatalogAdapter(uri, FileAccess.Read)); else ie.LoadRuleBase(new RuleML08DatalogAdapter(uri, FileAccess.Read)); } catch(Exception) { // the fall-back policy failed, hence throw the original exception throw firstAttemptException; } } } } break; case ".hrf": if (onlyFacts) ie.LoadFacts(new HRF086Adapter(uri, FileAccess.Read)); else ie.LoadRuleBase(new HRF086Adapter(uri, FileAccess.Read)); break; case ".vdx": string[] selectedPages = mf.PromptForVisioPageNameSelection(Visio2003Adapter.GetPageNames(uri)); if (selectedPages != null) { if (onlyFacts) ie.LoadFacts(new Visio2003Adapter(uri, FileAccess.Read, selectedPages)); else ie.LoadRuleBase(new Visio2003Adapter(uri, FileAccess.Read, (DialogResult.Yes == MessageBox.Show(mf, "Is your Visio rule base using strict syntax?", "Visio strictness", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)), selectedPages)); } break; default: throw new Exception(Path.GetExtension(uri) + " is an unknown extension."); } }
public void DestroyIE() { ie = null; Console.WriteLine("DestroyIE()"); }
/// <summary> /// Creates a new Reasoner Graph which is a wrapper around an existing Graph with a reasoner applied and the resulting Triples materialised. /// </summary> /// <param name="g">Graph.</param> /// <param name="reasoner">Reasoner.</param> public ReasonerGraph(IGraph g, IInferenceEngine reasoner) { _baseGraph = g; _reasoners.Add(reasoner); Initialise(); }