예제 #1
0
        public static void ManualSystem(Defuzzifier def, FuzzySystem fsAkcel, FuzzySystem fsKormilo)
        {
            int L, D, LK, DK, V, S, A, K;

            while (true)
            {
                Console.WriteLine("Unesi L D LK DK V S        ||  ili 'K' za kraj");
                String str = Console.ReadLine();

                if (str[0] == 'K')
                {
                    break;
                }

                String[] p = str.Split(' ');

                L  = int.Parse(p[0]);
                D  = int.Parse(p[1]);
                LK = int.Parse(p[2]);
                DK = int.Parse(p[3]);
                V  = int.Parse(p[4]);
                S  = int.Parse(p[5]);


                A = fsAkcel.Zakljuci(L, D, LK, DK, V, S);
                //A = 4;
                K = fsKormilo.Zakljuci(L, D, LK, DK, V, S);
                //K = 5;
                //akcel = 10; kormilo = 5;
                Console.Write("Akcel:" + A.ToString() + " Kormilo:" + K.ToString() + "\r\n");
                Console.Out.Flush();
            }
        }
예제 #2
0
        private static void Pravilo(Defuzzifier def, FuzzySystem fsAkcel, FuzzySystem fsKormilo)
        {
            Console.WriteLine("Unesite slovo baze (kor/akc) i redni broj pravila: (npr. 'k2') ");
            string pravilo = Console.ReadLine();

            FuzzySystem.ManualSingleRule(pravilo, def, fsAkcel, fsKormilo);
            Console.ReadKey();
        }
예제 #3
0
        public AkcelFuzzySystem(Defuzzifier defuzzifier)
        {
            this.defuzzifier = defuzzifier;

            IDomain acceleration = Domain.IntRange(-5, 6);
            IDomain direction    = Domain.IntRange(0, 2);
            IDomain distance     = Domain.IntRange(0, 1301);
            IDomain velocity     = Domain.IntRange(0, 100);

            MutableFuzzySet Id = new MutableFuzzySet(distance);
            MutableFuzzySet Iv = new MutableFuzzySet(velocity);

            foreach (var element in distance)
            {
                Id.Set(element, 1);
            }
            foreach (var element in velocity)
            {
                Iv.Set(element, 1);
            }

            IFuzzySet Slow   = new CalculatedFuzzySet(velocity, StandardFuzzySets.LFunction(0, 40));
            IFuzzySet Medium = new CalculatedFuzzySet(velocity, StandardFuzzySets.LambdaFunction(37, 45, 55));
            IFuzzySet Fast   = new CalculatedFuzzySet(velocity, StandardFuzzySets.GammaFunction(48, 60));

            IFuzzySet CriticalClose = new CalculatedFuzzySet(distance, StandardFuzzySets.LFunction(10, 30));
            IFuzzySet Close         = new CalculatedFuzzySet(distance, StandardFuzzySets.LFunction(25, 50));
            IFuzzySet Far           = new CalculatedFuzzySet(distance, StandardFuzzySets.GammaFunction(70, 100));

            IFuzzySet Backward = new MutableFuzzySet(direction).Set(DomainElement.Of(0), 1);
            IFuzzySet Forward  = new MutableFuzzySet(direction).Set(DomainElement.Of(1), 1);

            IFuzzySet SpeedUp = new MutableFuzzySet(acceleration)
                                .Set(DomainElement.Of(5), 1)
                                .Set(DomainElement.Of(4), 0.6)
                                .Set(DomainElement.Of(3), 0.3);
            IFuzzySet Neutral  = new MutableFuzzySet(acceleration).Set(DomainElement.Of(0), 1);
            IFuzzySet SlowDown = new MutableFuzzySet(acceleration)
                                 .Set(DomainElement.Of(-5), 1)
                                 .Set(DomainElement.Of(-4), 0.6)
                                 .Set(DomainElement.Of(-3), 0.3);

            // L, D, LK, RK, V, S
            rules = new List <Rule>();
            rules.Add(new Rule(new[] { Id, Id, CriticalClose, Id, Iv, Forward }, Neutral, tNorm, implication));
            rules.Add(new Rule(new[] { Id, Id, Id, CriticalClose, Iv, Forward }, Neutral, tNorm, implication));
            rules.Add(new Rule(new[] { Id, Id, CriticalClose, Id, Iv, Backward }, Neutral, tNorm, implication));
            rules.Add(new Rule(new[] { Id, Id, Id, CriticalClose, Iv, Backward }, Neutral, tNorm, implication));

            rules.Add(new Rule(new[] { Id, Id, Id, Id, Fast, Forward }, SlowDown, tNorm, implication));
            rules.Add(new Rule(new[] { Id, Id, Id, Id, Medium, Forward }, Neutral, tNorm, implication));
            rules.Add(new Rule(new[] { Id, Id, Id, Id, Slow, Forward }, SpeedUp, tNorm, implication));
        }
예제 #4
0
        internal static void ManualSingleRule(string pravilo, Defuzzifier def, FuzzySystem fsAkcel, FuzzySystem fsKormilo)
        {
            int L, D, LK, DK, V, S, A, K;


            if (pravilo[0] == 'a' || pravilo[0] == 'A')
            {
                int redni = int.Parse(pravilo[1].ToString());

                Console.WriteLine("Unesi L D LK DK V S");
                String   str = Console.ReadLine();
                String[] p   = str.Split(' ');

                L  = int.Parse(p[0]);
                D  = int.Parse(p[1]);
                LK = int.Parse(p[2]);
                DK = int.Parse(p[3]);
                V  = int.Parse(p[4]);
                S  = int.Parse(p[5]);

                fsAkcel.ZakljuciPrint(L, D, LK, DK, V, S, fsAkcel.AkcelRules[redni]);
            }

            else if (pravilo[0] == 'k' || pravilo[0] == 'K')
            {
                int redni = int.Parse(pravilo[1].ToString());

                Console.WriteLine("Unesi L D LK DK V S");
                String   str = Console.ReadLine();
                String[] p   = str.Split(' ');

                L  = int.Parse(p[0]);
                D  = int.Parse(p[1]);
                LK = int.Parse(p[2]);
                DK = int.Parse(p[3]);
                V  = int.Parse(p[4]);
                S  = int.Parse(p[5]);

                fsKormilo.ZakljuciPrint(L, D, LK, DK, V, S, fsKormilo.KormiloRules[redni]);
            }
        }
예제 #5
0
 private static void Manual(Defuzzifier def, FuzzySystem fsAkcel, FuzzySystem fsKormilo)
 {
     FuzzySystem.ManualSystem(def, fsAkcel, fsKormilo);
 }
예제 #6
0
        public KormiloFuzzySystem(Defuzzifier defuzzifier)
        {
            this.defuzzifier = defuzzifier;

            IDomain angle     = Domain.IntRange(-90, 91);
            IDomain direction = Domain.IntRange(0, 2);
            IDomain distance  = Domain.IntRange(0, 1301);
            IDomain velocity  = Domain.IntRange(0, 100);

            MutableFuzzySet Id = new MutableFuzzySet(distance);
            MutableFuzzySet Iv = new MutableFuzzySet(velocity);

            foreach (var element in distance)
            {
                Id.Set(element, 1);
            }
            foreach (var element in velocity)
            {
                Iv.Set(element, 1);
            }

            //IFuzzySet CriticalClose = new CalculatedFuzzySet(distance, StandardFuzzySets.LFunction(20, 40));
            IFuzzySet Close   = new CalculatedFuzzySet(distance, StandardFuzzySets.LFunction(40, 90));
            IFuzzySet Far     = new CalculatedFuzzySet(distance, StandardFuzzySets.GammaFunction(100, 200));
            IFuzzySet VeryFar = new CalculatedFuzzySet(distance, StandardFuzzySets.GammaFunction(300, 400));
            //IFuzzySet NotFar = Operations.UnaryOperation(Far, Operations.ZadehNot());

            IFuzzySet Backward = new MutableFuzzySet(direction).Set(DomainElement.Of(0), 1);
            IFuzzySet Forward  = new MutableFuzzySet(direction).Set(DomainElement.Of(1), 1);

            IFuzzySet Left = new MutableFuzzySet(angle).Set(DomainElement.Of(90), 1);
            //IFuzzySet Left = new CalculatedFuzzySet(angle, StandardFuzzySets.LambdaFunction(0, 30, 50));
            //IFuzzySet FullLeft = new CalculatedFuzzySet(angle, StandardFuzzySets.LambdaFunction(55, 70, 80));

            IFuzzySet Neutral = new CalculatedFuzzySet(angle, StandardFuzzySets.LambdaFunction(-10, 0, 10));

            //IFuzzySet Right = new CalculatedFuzzySet(angle, StandardFuzzySets.LambdaFunction(-50, -30, 0));
            IFuzzySet Right = new MutableFuzzySet(angle).Set(DomainElement.Of(-90), 1);

            //IFuzzySet FullRight = new CalculatedFuzzySet(angle, StandardFuzzySets.LambdaFunction(-80, -70, -55));


            // L, D, LK, RK, V, S
            rules = new List <Rule>();
            rules.Add(new Rule(new[] { Id, Close, Id, Id, Iv, Forward }, Left, tNorm, implication));
            rules.Add(new Rule(new[] { Close, Id, Id, Id, Iv, Forward }, Right, tNorm, implication));

            rules.Add(new Rule(new[] { Id, Id, Id, Close, Iv, Forward }, Left, tNorm, implication));
            rules.Add(new Rule(new[] { Id, Id, Close, Id, Iv, Forward }, Right, tNorm, implication));

            rules.Add(new Rule(new[] { VeryFar, Id, Id, Id, Iv, Backward }, Left, tNorm, implication));
            rules.Add(new Rule(new[] { Id, VeryFar, Id, Id, Iv, Backward }, Right, tNorm, implication));


            //rules.Add(new Rule(new[] { Far, Close, Id, Id, Iv, Forward }, Left, tNorm, implication));
            //rules.Add(new Rule(new[] { Id, Close, Id, CriticalClose, Iv, Forward }, FullLeft));
            //rules.Add(new Rule(new[] { Far, Close, Id, Id, Iv, Backward }, Left, tNorm, implication));

            //rules.Add(new Rule(new[] { Far, Far, Id, Id, Iv, Forward }, Neutral));

            //rules.Add(new Rule(new[] { Close, Far, Id, Id, Iv, Forward }, Right, tNorm, implication));
            //rules.Add(new Rule(new[] { Close, Id, CriticalClose, Id, Iv, Forward }, FullRight));
            //rules.Add(new Rule(new[] { Close, Far, Id, Id, Iv, Backward }, Right, tNorm, implication));


            //rules.Add(new Rule(new[] { Far, Id, Close, Close, Iv, Forward }, Left, tNorm, implication));
            //rules.Add(new Rule(new[] { Id, Far, Close, Close, Iv, Forward }, Right, tNorm, implication));
            //rules.Add(new Rule(new[] { VeryFar, VeryFar, Close, Close, Iv, Forward }, Right, tNorm, implication));

            //rules.Add(new Rule(new[] { Far, Id, Close, Close, Iv, Backward }, Right, tNorm, implication));
            ////rules.Add(new Rule(new[] { Id, Far, Close, Close, Iv, Backward }, Left, tNorm, implication));


            //rules.Add(new Rule(new[] { Close, Close, Id, Close, Iv, Forward }, Left, tNorm, implication));
            //rules.Add(new Rule(new[] { Close, Close, Close, Id, Iv, Forward }, Right, tNorm, implication));

            //rules.Add(new Rule(new[] { Id, Id, Id, Id, Iv, Backward }, Right, tNorm, implication));

            //rules.Add(new Rule(new[] { VeryFar, Id, Close, Close, Iv, Forward }, Right, tNorm, implication));
            //rules.Add(new Rule(new[] { Id, VeryFar, Close, Close, Iv, Forward }, Left, tNorm, implication));
        }
 public KormiloFuzzySystemMin(Defuzzifier def)
 {
     this.def = def;
     KormiloRuleBook();
 }
 public AkcelFuzzySystemMin(Defuzzifier def)
 {
     this.def = def;
     AkcelRuleBook();
 }