Ejemplo n.º 1
0
        public ExpertOpinion GetResult(string profileName)
        {
            var initialData   = _initialDataProvider.GetInitialData();
            var knowledgeBase = _knowledgeManager.GetKnowledgeBase(profileName);

            var opinion = new ExpertOpinion();

            if (!initialData.IsPresent)
            {
                opinion.AddErrorMessage("Initial data is not consistent. Check logs for more information.");
            }
            if (!knowledgeBase.IsPresent)
            {
                opinion.AddErrorMessage("Knowledge base is not consistent. Check logs for more information.");
            }

            ValidateInitialDataAgainstKnowledgeBase(initialData, knowledgeBase, opinion);
            if (!opinion.IsSuccess)
            {
                return(opinion);
            }

            _inferenceEngine.InitializeEngine();
            FillInferenceEngineRules(knowledgeBase.Value);
            var activatedNodes   = GetInitialNodes(knowledgeBase.Value, initialData.Value);
            var inferenceResults = _inferenceEngine.GetInferenceResults(activatedNodes);

            opinion.AddResults(DeFuzzifyResults(inferenceResults, knowledgeBase.Value.LinguisticVariables));
            return(opinion);
        }
Ejemplo n.º 2
0
        public void AddResult_AddMessagesToErrorMessagesList()
        {
            // Arrange
            double firstExpectedConfidenceFactor  = 50;
            string firstExpectedNodeName          = "A1";
            double firstExpectedDeFuzzifiedValue  = 2;
            double secondExpectedConfidenceFactor = 100;
            string secondExpectedNodeName         = "B1";
            double secondExpectedDeFuzzifiedValue = 3;
            var    results = new List <DeFuzzifiedInferenceResult>
            {
                new DeFuzzifiedInferenceResult(firstExpectedNodeName, firstExpectedConfidenceFactor, firstExpectedDeFuzzifiedValue),
                new DeFuzzifiedInferenceResult(secondExpectedNodeName, secondExpectedConfidenceFactor, secondExpectedDeFuzzifiedValue)
            };

            // Act
            _expertOpinion.AddResults(results);

            // Assert
            Assert.IsTrue(_expertOpinion.IsSuccess);
            Assert.AreEqual(2, _expertOpinion.Result.Count);
            Assert.AreEqual(firstExpectedConfidenceFactor, _expertOpinion.Result[0].ConfidenceFactor);
            Assert.AreEqual(secondExpectedConfidenceFactor, _expertOpinion.Result[1].ConfidenceFactor);
        }