Example #1
0
        private FuzzySubexpression AddPremiseImpl(FuzzyConnectiveType?conjunction, FuzzyValue fuzzyValue)
        {
            FuzzySubexpression subexpr;

            if (this.premise.Count == 0)
            {
                subexpr = new FuzzySubexpression(FuzzyConnectiveType.None, fuzzyValue);
            }
            else
            {
                subexpr = new FuzzySubexpression(conjunction ?? FuzzyConnectiveType.And, fuzzyValue);
            }

            this.premise.Add(subexpr);
            return(subexpr);
        }
Example #2
0
        public FuzzySubexpression AddConclusion(FuzzyValue fuzzyValue)
        {
            FuzzySubexpression fs;

            if (this.conclusion.Count == 0)
            {
                fs = new FuzzySubexpression(FuzzyConnectiveType.None, fuzzyValue);
            }
            else
            {
                fs = new FuzzySubexpression(FuzzyConnectiveType.And, fuzzyValue);
            }

            this.conclusion.Add(fs);
            return(fs);
        }
Example #3
0
        public FuzzySubexpression AddEmptyConclusion()
        {
            FuzzySubexpression fs;

            if (this.conclusion.Count == 0)
            {
                fs = new FuzzySubexpression(FuzzyConnectiveType.None, null);
            }
            else
            {
                fs = new FuzzySubexpression(FuzzyConnectiveType.And, null);
            }

            this.conclusion.Add(fs);
            return(fs);
        }
Example #4
0
        public FuzzyRule Clone()
        {
            FuzzyRule copy = new FuzzyRule();

            foreach (FuzzySubexpression fs in this.premise)
            {
                FuzzySubexpression fs_copy = fs.Clone();
                copy.premise.Add(fs_copy);
            }
            foreach (FuzzySubexpression fs in this.conclusion)
            {
                FuzzySubexpression fs_copy = fs.Clone();
                copy.conclusion.Add(fs_copy);
            }
            return(copy);
        }
Example #5
0
        public bool RemoveConclusion(FuzzySubexpression subexpression)
        {
            if (!this.conclusion.Contains(subexpression))
            {
                return(false);
            }

            this.conclusion.Remove(subexpression);

            // W pierwszej konkluzji usuń spójnik; nie ma on w takim przypadku sensu.
            if (this.conclusion.Count > 0 && this.conclusion[0].ConnectiveType != FuzzyConnectiveType.None)
            {
                this.conclusion[0].ConnectiveType = FuzzyConnectiveType.None;
            }

            return(true);
        }