Esempio n. 1
0
        public FuzzyObject <Enum> And(Enum value)
        {
            if (_fuzzyLogic == null)
            {
                return(new FuzzyObject <Enum>());
            }
            double otherDegree  = _fuzzyLogic.GetDegree(value);
            double resultDegree = _fuzzyLogic.GetAndDegree(Degree, otherDegree);

            return(new FuzzyObject <Enum>(Value, resultDegree, _fuzzyLogic));
        }
Esempio n. 2
0
        private IPuzzleAction GetDecisionByMemory(ISensationSnapshot snapshot)
        {
            // FUZZY-Logic: Entscheiden welcher Modus aktiv sein sollte
            if (_actionFeedbackHistory.Any())
            {
                var percentagePositive = (double)_actionFeedbackHistory.Count(e => e > 0) / _actionFeedbackHistory.Count;
                var percentageNegative = (double)_actionFeedbackHistory.Count(e => e < 0) / _actionFeedbackHistory.Count;
                var percentageNeutral  = (double)_actionFeedbackHistory.Count(e => e == 0) / _actionFeedbackHistory.Count;

                _fillAPixFuzzyLogic.SetValue <FuzzyPositiveHistoryTypes>(percentagePositive);
                _fillAPixFuzzyLogic.SetValue <FuzzyErrorHistoryTypes>(percentageNegative);
                _fillAPixFuzzyLogic.SetValue <FuzzyNeutralHistoryTypes>(percentageNeutral);

                _fillAPixFuzzyLogic.CalculateOutput();
                double learningDegree = _fillAPixFuzzyLogic.GetDegree(FuzzyInteractionModeTypes.Learning);
                double solvingDegree  = _fillAPixFuzzyLogic.GetDegree(FuzzyInteractionModeTypes.Solving);
                double hundredPercent = learningDegree + solvingDegree;
                if (hundredPercent > 0)
                {
                    PercentageSolving = solvingDegree / hundredPercent * 100;
                }
            }

            double positionInRangeByRandom = _random.NextDouble();
            Dictionary <IPuzzleAction, IActionMemoryQuartet> rangeOfActions = GetRangeOfActions(snapshot, RiskFactor);

            foreach (var rangeOfAction in rangeOfActions)
            {
                var stepSize = rangeOfAction.Value.StepSize;
                if (stepSize >= positionInRangeByRandom)
                {
                    return(rangeOfAction.Key);
                }
                positionInRangeByRandom -= stepSize;
            }
            return(null);
        }