Esempio n. 1
0
 private void SetOutputValues()
 {
     damage = new LinguisticVariable("Damage", 0, 100);
     damage.AddValue(new LinguisticValue("Poco", new LeftFuzzySet(0, 100, 5, 20)));
     damage.AddValue(new LinguisticValue("Normal", new TrapezoidalFuzzySet(0, 100, 5, 20, 50, 70)));
     damage.AddValue(new LinguisticValue("Mucho", new RightFuzzySet(0, 100, 50, 70)));
     system.addOutputVariable(damage);
 }
Esempio n. 2
0
    private void SetInputValues()
    {
        //Distancia enemigo(m)
        distancia = new LinguisticVariable("Distancia", 0, 100);
        distancia.AddValue(new LinguisticValue("Poca", new LeftFuzzySet(0, 100, 5, 15)));
        distancia.AddValue(new LinguisticValue("Media", new TrapezoidalFuzzySet(0, 100, 5, 15, 60, 70)));
        distancia.AddValue(new LinguisticValue("Mucha", new RightFuzzySet(0, 100, 60, 70)));
        system.addInputVariable(distancia);

        //Velocidad proyectil(m/s)
        velocidad = new LinguisticVariable("Velocidad", 0, 300);
        velocidad.AddValue(new LinguisticValue("Poca", new LeftFuzzySet(0, 300, 30, 50)));
        velocidad.AddValue(new LinguisticValue("Media", new TrapezoidalFuzzySet(0, 300, 40, 50, 100, 150)));
        velocidad.AddValue(new LinguisticValue("Mucha", new TrapezoidalFuzzySet(0, 300, 100, 150, 200, 240)));
        velocidad.AddValue(new LinguisticValue("Muchisima", new RightFuzzySet(0, 300, 240, 270)));
        system.addInputVariable(velocidad);

        //Peso proyectil (Kg)
        peso = new LinguisticVariable("Peso", 0, 50);
        peso.AddValue(new LinguisticValue("Poco", new LeftFuzzySet(0, 50, 0, 5)));
        peso.AddValue(new LinguisticValue("Medio", new TrapezoidalFuzzySet(0, 50, 0, 5, 20, 30)));
        peso.AddValue(new LinguisticValue("Mucho", new RightFuzzySet(0, 50, 30, 40)));
        system.addInputVariable(peso);
    }
Esempio n. 3
0
        static void Main(string[] args)
        {
            //Point2D pt1 = new Point2D(0, 0);
            //Point2D pt2 = new Point2D(15, 0);
            //Point2D pt3 = new Point2D(17, 1);
            //Point2D pt4 = new Point2D(20, 1);
            //Point2D pt5 = new Point2D(25, 0);
            //Point2D pt6 = new Point2D(15, 0);


            //Console.WriteLine("Test Classe Point2D :");
            //Console.WriteLine("(15;0) == (15;0)" + (pt2 == pt6));
            //Console.WriteLine("(15;0) != (17;0)" + (pt2 != pt3));
            //Console.WriteLine("(15;0) > (17;1)" + (pt2 > pt3));
            //Console.WriteLine("(15;0) < (17;1)" + (pt2 < pt3));
            //Console.WriteLine("(15;0) > (15;0)" + (pt2 > pt6));
            //Console.WriteLine("(15;0) < (15;0)" + (pt2 < pt6));
            //Console.WriteLine("(15;0) >= (15;0)" + (pt2 >= pt6));
            //Console.WriteLine("(15;0) <= (15;1)" + (pt2 <= pt6));

            //Console.WriteLine("\nTest Classe FuzzySet :");
            //Point2D[] array = { pt5, pt2, pt6, pt4, pt1, pt3 };
            //FuzzySet fs = new FuzzySet(array);
            //Console.WriteLine("\n" + fs.ToString());

            //List<Point2D> list = new List<Point2D>();
            //list.Add(pt5);
            //list.Add(pt2);
            //list.Add(pt6);
            //list.Add(pt4);
            //list.Add(pt1);
            //list.Add(pt3);

            //FuzzySet fs2 = new FuzzySet(list);
            //fs2.Max = 53;
            //Console.WriteLine("\n" + fs2.ToString());
            //fs2.AddPoint(-9, 0.98);
            //fs2.Min = -8;
            //Console.WriteLine("\n" + fs2.ToString());
            //Console.WriteLine("Egalité des 2 ensembles flous ? " + (fs == fs2));
            //Console.WriteLine("Différence entre les 2 ensembles flous ? " + (fs != fs2));

            //FuzzySet fs3 = fs * 0.5;
            //FuzzySet fs4 = 0.5 * fs;
            //Console.WriteLine("Multiplication par 0.5 de fs : " + fs3.ToString());
            //Console.WriteLine("Multiplication par 0.5 de fs (autre sens) : " + fs4.ToString());
            //FuzzySet fs5 = !fs;
            //Console.WriteLine("Opération NON flou sur fs : " + fs5.ToString());
            //Console.WriteLine("Valeur d'appartenance de fs à x=15,5 (0,25 normalement) : " + fs.DegreeAtValue(15.5));
            //Console.WriteLine("Calcul du barycentre pour fs : " + fs.Barycenter);

            //RampFuzzySet rfs = new RampFuzzySet(11.54, 26.56);
            //Console.WriteLine("Test classe RampFuzzySet : \n" + rfs.ToString());
            //Console.WriteLine("Calcul du barycentre pour lfs : " + rfs.Barycenter);

            //TriangularFuzzySet tfs = new TriangularFuzzySet(52.25, 12.56, 25.89);
            //Console.WriteLine("Test classe TriangularFuzzySet : \n" + tfs.ToString());
            //Console.WriteLine("Calcul du barycentre pour tfs : " + tfs.Barycenter);

            //TrapezoidalFuzzySet trfs = new TrapezoidalFuzzySet(25.2, 5, 89.45, 39.45);
            //Console.WriteLine("Test classe TrapezoidalFuzzySet : \n" + trfs.ToString());
            //Console.WriteLine("Calcul du barycentre pour trfs : " + trfs.Barycenter);

            //Console.WriteLine("\nTest classe LinguisticVariable :");
            //LinguisticValue lv1 = new LinguisticValue("LV1", rfs);
            //LinguisticValue lv2 = new LinguisticValue("LV2", tfs);
            //LinguisticValue lv3 = new LinguisticValue("LV3", trfs);
            //List<LinguisticValue> listeLv1 = new List<LinguisticValue>();
            //listeLv1.Add(lv1);
            //listeLv1.Add(lv2);
            //listeLv1.Add(lv3);
            //LinguisticVariable lVar1 = new LinguisticVariable("Variable linguistique 1", listeLv1, 3.56, 141.25);
            //Console.WriteLine("MinValue = " + lVar1.MinValue + ", MaxValue = " + lVar1.MaxValue);


            // Test algorithme flou avec problème de gestion du zoom GPS
            // Définition variable linguistique 1 (Premisse)
            LinguisticVariable distance = new LinguisticVariable("Distance");

            distance.AddValue(new LinguisticValue("faible", new RampFuzzySet(30, 50, 0, 500000)));
            distance.AddValue(new LinguisticValue("moyenne", new TrapezoidalFuzzySet(40, 50, 100, 150, 0, 500000)));
            distance.AddValue(new LinguisticValue("grande", new RampFuzzySet(150, 100, 0, 500000)));
            Console.WriteLine("Contrôle de la variable linguistique distance : " + distance.MinValue + " " + distance.MaxValue);
            // Définition variable linguistique 2 (Premisse)
            LinguisticVariable vitesse = new LinguisticVariable("Vitesse");

            vitesse.AddValue(new LinguisticValue("lente", new RampFuzzySet(20, 30, 0, 200)));
            vitesse.AddValue(new LinguisticValue("peu rapide", new TrapezoidalFuzzySet(20, 30, 70, 80, 0, 200)));
            vitesse.AddValue(new LinguisticValue("rapide", new TrapezoidalFuzzySet(70, 80, 90, 110, 0, 200)));
            vitesse.AddValue(new LinguisticValue("très rapide", new RampFuzzySet(110, 90, 0, 200)));
            Console.WriteLine("Contrôle de la variable linguistique vitesse : " + vitesse.MinValue + " " + vitesse.MaxValue);
            // Définition variable linguistique 3 (Conclusion)
            LinguisticVariable zoom = new LinguisticVariable("Zoom");

            zoom.AddValue(new LinguisticValue("petit", new RampFuzzySet(1, 2, 0, 5)));
            zoom.AddValue(new LinguisticValue("normal", new TrapezoidalFuzzySet(1, 2, 3, 4, 0, 5)));
            zoom.AddValue(new LinguisticValue("gros", new RampFuzzySet(4, 3, 0, 5)));
            Console.WriteLine("Contrôle de la variable linguistique zoom : " + zoom.MinValue + " " + zoom.MaxValue);

            List <LinguisticVariable> listeLinguisticVariable = new List <LinguisticVariable>();

            listeLinguisticVariable.Add(distance);
            listeLinguisticVariable.Add(vitesse);

            // Définition des FuzzeExpression
            FuzzyExpression exp11 = new FuzzyExpression(distance, "faible");
            FuzzyExpression exp12 = new FuzzyExpression(distance, "moyenne");
            FuzzyExpression exp13 = new FuzzyExpression(distance, "grande");
            FuzzyExpression exp21 = new FuzzyExpression(vitesse, "lente");
            FuzzyExpression exp22 = new FuzzyExpression(vitesse, "peu rapide");
            FuzzyExpression exp23 = new FuzzyExpression(vitesse, "rapide");
            FuzzyExpression exp24 = new FuzzyExpression(vitesse, "très rapide");
            FuzzyExpression exp31 = new FuzzyExpression(zoom, "petit");
            FuzzyExpression exp32 = new FuzzyExpression(zoom, "normal");
            FuzzyExpression exp33 = new FuzzyExpression(zoom, "gros");
            // Définition des règles
            List <FuzzyExpression> premises = new List <FuzzyExpression>();
            FuzzyExpression        conclusion;
            List <FuzzyRule>       rules = new List <FuzzyRule>();

            // Règle 1
            premises.Add(exp11);
            premises.Add(exp21);
            conclusion = exp32;
            rules.Add(new FuzzyRule(new List <FuzzyExpression>(premises), conclusion));
            premises.Clear();

            // Règle 2
            premises.Add(exp12);
            premises.Add(exp21);
            conclusion = exp31;
            rules.Add(new FuzzyRule(new List <FuzzyExpression>(premises), conclusion));
            premises.Clear();

            // Règle 3
            premises.Add(exp11);
            premises.Add(exp22);
            conclusion = exp32;
            rules.Add(new FuzzyRule(new List <FuzzyExpression>(premises), conclusion));
            premises.Clear();

            // Règle 4
            premises.Add(exp12);
            premises.Add(exp22);
            conclusion = exp32;
            rules.Add(new FuzzyRule(new List <FuzzyExpression>(premises), conclusion));
            premises.Clear();

            // Règle 5
            premises.Add(exp11);
            premises.Add(exp23);
            conclusion = exp33;
            rules.Add(new FuzzyRule(new List <FuzzyExpression>(premises), conclusion));
            premises.Clear();

            // Règle 6
            premises.Add(exp12);
            premises.Add(exp23);
            conclusion = exp32;
            rules.Add(new FuzzyRule(new List <FuzzyExpression>(premises), conclusion));
            premises.Clear();

            // Règle 7
            premises.Add(exp11);
            premises.Add(exp24);
            conclusion = exp33;
            rules.Add(new FuzzyRule(new List <FuzzyExpression>(premises), conclusion));
            premises.Clear();

            // Règle 8
            premises.Add(exp12);
            premises.Add(exp24);
            conclusion = exp33;
            rules.Add(new FuzzyRule(new List <FuzzyExpression>(premises), conclusion));
            premises.Clear();

            // Règle 9
            premises.Add(exp13);
            conclusion = exp31;
            rules.Add(new FuzzyRule(new List <FuzzyExpression>(premises), conclusion));
            premises.Clear();

            // Création du FuzzySystem
            FuzzySystem system = new FuzzySystem("Gestion du zoom GPS", listeLinguisticVariable, zoom, rules);

            // Cas 1
            system.SetInputVariable(distance, 70);
            system.SetInputVariable(vitesse, 35);
            Console.WriteLine("GPS cas n°1 (70m et 35km/h) : " + system.Solve());
            system.ResetCase();

            // Cas 2
            system.SetInputVariable(distance, 70);
            system.SetInputVariable(vitesse, 25);
            Console.WriteLine("GPS cas n°1 (70m et 25km/h) : " + system.Solve());
            system.ResetCase();

            // Cas 3
            system.SetInputVariable(distance, 40);
            system.SetInputVariable(vitesse, 72.5);
            Console.WriteLine("GPS cas n°1 (40m et 72,5km/h) : " + system.Solve());
            system.ResetCase();

            // Cas 4
            system.SetInputVariable(distance, 110);
            system.SetInputVariable(vitesse, 100);
            Console.WriteLine("GPS cas n°1 (110m et 100km/h) : " + system.Solve());
            system.ResetCase();

            // Cas 5
            system.SetInputVariable(distance, 160);
            system.SetInputVariable(vitesse, 45);
            Console.WriteLine("GPS cas n°1 (160m et 45km/h) : " + system.Solve());
            system.ResetCase();


            // Test Parsin fichier XML
            Console.WriteLine("\n\nTEST PARSING FICHIER XML");
            XmlFuzzySystemParser parser = new XmlFuzzySystemParser();

            parser.CreateFuzzySystem("Fuzzy System - Gestion zoom GPS.xml");
            Console.WriteLine("Résultat parsing = " + parser.ErrorCode.ToString());
            List <LinguisticVariable> _inputs = parser.GetInputs();
            LinguisticVariable        _output = parser.GetOutput();
            List <FuzzyRule>          _rules  = parser.GetRules();

            // Création du FuzzySystem
            system = new FuzzySystem("Gestion du zoom GPS", _inputs, _output, _rules);
            // Cas 1
            system.SetInputVariable(_inputs[0], 70);
            system.SetInputVariable(_inputs[1], 35);
            Console.WriteLine("GPS cas n°1 (70m et 35km/h) : " + system.Solve());
            system.ResetCase();

            // Cas 2
            system.SetInputVariable(_inputs[0], 70);
            system.SetInputVariable(_inputs[1], 25);
            Console.WriteLine("GPS cas n°1 (70m et 25km/h) : " + system.Solve());
            system.ResetCase();

            // Cas 3
            system.SetInputVariable(_inputs[0], 40);
            system.SetInputVariable(_inputs[1], 72.5);
            Console.WriteLine("GPS cas n°1 (40m et 72,5km/h) : " + system.Solve());
            system.ResetCase();

            // Cas 4
            system.SetInputVariable(_inputs[0], 110);
            system.SetInputVariable(_inputs[1], 100);
            Console.WriteLine("GPS cas n°1 (110m et 100km/h) : " + system.Solve());
            system.ResetCase();

            // Cas 5
            system.SetInputVariable(_inputs[0], 160);
            system.SetInputVariable(_inputs[1], 45);
            Console.WriteLine("GPS cas n°1 (160m et 45km/h) : " + system.Solve());
            system.ResetCase();



            Console.ReadKey();
        }
Esempio n. 4
0
        void Update()
        {
            distanciaCentro = Vector3.Distance(centro.position, playerPosition.position);
            if (tiempoRest > 0)
            {
                tiempoRest -= Time.deltaTime;
            }

            // Creación del sistema
            WriteLine("Gestión de la velocidad de los enemigos", true);
            FuzzySystem system = new FuzzySystem("Gestión de la velocidad de los enemigos");

            WriteLine("1) Agregar las variables", true);

            // Agregar la variable lingüística "Proximidad" (de 0 a 95 m)
            WriteLine("Agregar la variable Proximidad");
            LinguisticVariable proximidad = new LinguisticVariable("Proximidad", 0, 95);

            proximidad.AddValue(new LinguisticValue("Cerca", new LeftFuzzySet(0, 95, 0, 30)));
            proximidad.AddValue(new LinguisticValue("Media", new TrapezoidalFuzzySet(0, 95, 0, 30, 20, 50)));
            proximidad.AddValue(new LinguisticValue("Lejos", new RightFuzzySet(0, 95, 40, 65)));
            system.addInputVariable(proximidad);

            // Agregar la variable lingüística "Tiempo" (de 0 a 200 s)
            WriteLine("Agregar la variable Tiempo");
            LinguisticVariable tiempo = new LinguisticVariable("Tiempo", 0, 200);

            tiempo.AddValue(new LinguisticValue("Muy Poco", new LeftFuzzySet(0, 200, 40, 60)));
            tiempo.AddValue(new LinguisticValue("Poco", new TrapezoidalFuzzySet(0, 200, 40, 60, 90, 110)));
            tiempo.AddValue(new LinguisticValue("Mitad", new TrapezoidalFuzzySet(0, 200, 90, 110, 140, 160)));
            tiempo.AddValue(new LinguisticValue("Mucho", new RightFuzzySet(0, 200, 140, 160)));
            system.addInputVariable(tiempo);

            // Agregar la variable lingüística "Velocidad" (de 500 a 5000)
            WriteLine("Agregar la variable Velocidad");
            LinguisticVariable velocidad = new LinguisticVariable("Velocidad", 500, 5000);

            velocidad.AddValue(new LinguisticValue("Lenta", new LeftFuzzySet(500, 5000, 1000, 2000)));
            velocidad.AddValue(new LinguisticValue("Normal", new TrapezoidalFuzzySet(500, 5000, 1000, 2000, 3000, 4000)));
            velocidad.AddValue(new LinguisticValue("Rápida", new RightFuzzySet(500, 5000, 3000, 4000)));
            system.addOutputVariable(velocidad);

            WriteLine("2) Agregar las reglas", true);

            // Creación de las reglas en función de la matriz siguiente:
            // Cuanto mayor sea la Proximidad y menor sea el Tiempo, más Velocidad tendrán.
            // P \ T    || L | M | C |
            // Muy Poco || N | R | R |
            // Poco     || N | N | R |
            // Mitad    || L | N | N |
            // Mucho    || L | L | N |
            system.addFuzzyRule("IF Proximidad IS Lejos AND Tiempo IS Muy Poco THEN Velocidad IS Normal");
            system.addFuzzyRule("IF Proximidad IS Lejos AND Tiempo IS Poco THEN Velocidad IS Normal");
            system.addFuzzyRule("IF Proximidad IS Lejos AND Tiempo IS Mitad THEN Velocidad IS Lenta");
            system.addFuzzyRule("IF Proximidad IS Lejos AND Tiempo IS Mucho THEN Velocidad IS Lenta");
            system.addFuzzyRule("IF Proximidad IS Media AND Tiempo IS Muy Poco THEN Velocidad IS Rápida");
            system.addFuzzyRule("IF Proximidad IS Media AND Tiempo IS Poco THEN Velocidad IS Normal");
            system.addFuzzyRule("IF Proximidad IS Media AND Tiempo IS Mitad THEN Velocidad IS Normal");
            system.addFuzzyRule("IF Proximidad IS Media AND Tiempo IS Mucho THEN Velocidad IS Lenta");
            system.addFuzzyRule("IF Proximidad IS Cerca AND Tiempo IS Muy Poco THEN Velocidad IS Rápida");
            system.addFuzzyRule("IF Proximidad IS Cerca AND Tiempo IS Poco THEN Velocidad IS Rápida");
            system.addFuzzyRule("IF Proximidad IS Cerca AND Tiempo IS Mitad THEN Velocidad IS Normal");
            system.addFuzzyRule("IF Proximidad IS Cerca AND Tiempo IS Mucho THEN Velocidad IS Normal");
            WriteLine("12 reglas agregadas \n");

            WriteLine("3) Resolución de casos prácticos", true);
            WriteLine("Caso 1:", true);
            WriteLine("T = 30 (Muy Poco)");
            WriteLine("P = 800 (Cerca)");
            system.SetInputVariable(tiempo, tiempoRest);
            system.SetInputVariable(proximidad, distanciaCentro);
            WriteLine("Resultado: " + system.Solve() + "\n");
            enemyVelocity = system.Solve();
            system.ResetCase();

            //// Caso práctico 2: Tiempo de 180s, proximidad a la meta de 280m
            //system.ResetCase();
            //WriteLine("Caso 2:", true);
            //WriteLine("T = 180 (Mucho)");
            //WriteLine("P = 280 (Lejos)");
            //system.SetInputVariable(tiempo, 180);
            //system.SetInputVariable(proximidad, 280);
            //WriteLine("Resultado: " + system.Solve() + "\n");

            //// Caso práctico 3: Tiempo de 70s, proximidad a la meta de 530m
            //system.ResetCase();
            //WriteLine("Caso 3:", true);
            //WriteLine("T = 70 (Poco)");
            //WriteLine("P = 530 (Media)");
            //system.SetInputVariable(tiempo, 70);
            //system.SetInputVariable(proximidad, 530);
            //WriteLine("Resultado: " + system.Solve() + "\n");

            //// Caso práctico 4: Tiempo de 120s, proximidad a la meta de 120m
            //system.ResetCase();
            //WriteLine("Caso 4:", true);
            //WriteLine("T = 120 (Mitad)");
            //WriteLine("P = 120 (Lejos)");
            //system.SetInputVariable(tiempo, 120);
            //system.SetInputVariable(proximidad, 120);
            //WriteLine("Resultado: " + system.Solve() + "\n");

            //// Caso práctico 5 : Tiempo de 10s, proximidad a la meta de 450m
            //system.ResetCase();
            //WriteLine("Caso 5:", true);
            //WriteLine("T = 10 (Muy Poco)");
            //WriteLine("P = 450 (Media)");
            //system.SetInputVariable(tiempo, 10);
            //system.SetInputVariable(proximidad, 450);
            //WriteLine("Resultado: " + system.Solve() + "\n");
        }
Esempio n. 5
0
    static void Main(string[] args)
    {
        // Création du système
        WriteLine("Gestion du zoom GPS", true);
        FuzzySystem system = new FuzzySystem("Gestion du zoom GPS");

        WriteLine("1) Ajout des variables", true);

        // Ajout de la variable linguistique "Distance" (de 0 à 500 000 m)
        WriteLine("Ajout de la variable Distance");
        LinguisticVariable distance = new LinguisticVariable("Distance", 0, 500000);

        distance.AddValue(new LinguisticValue("Faible", new LeftFuzzySet(0, 500000, 30, 50)));
        distance.AddValue(new LinguisticValue("Moyenne", new TrapezoidalFuzzySet(0, 500000, 40, 50, 100, 150)));
        distance.AddValue(new LinguisticValue("Grande", new RightFuzzySet(0, 500000, 100, 150)));
        system.addInputVariable(distance);

        // Ajout de la variable linguistique "Vitesse" (de 0 à 200)
        WriteLine("Ajout de la variable Vitesse");
        LinguisticVariable vitesse = new LinguisticVariable("Vitesse", 0, 200);

        vitesse.AddValue(new LinguisticValue("Lente", new LeftFuzzySet(0, 200, 20, 30)));
        vitesse.AddValue(new LinguisticValue("PeuRapide", new TrapezoidalFuzzySet(0, 200, 20, 30, 70, 80)));
        vitesse.AddValue(new LinguisticValue("Rapide", new TrapezoidalFuzzySet(0, 200, 70, 80, 90, 110)));
        vitesse.AddValue(new LinguisticValue("TresRapide", new RightFuzzySet(0, 200, 90, 110)));
        system.addInputVariable(vitesse);

        // Ajout de la variable linguistique "Zoom" (de 1 à 5)
        WriteLine("Ajout de la variable Zoom");
        LinguisticVariable zoom = new LinguisticVariable("Zoom", 0, 5);

        zoom.AddValue(new LinguisticValue("Petit", new LeftFuzzySet(0, 5, 1, 2)));
        zoom.AddValue(new LinguisticValue("Normal", new TrapezoidalFuzzySet(0, 5, 1, 2, 3, 4)));
        zoom.AddValue(new LinguisticValue("Gros", new RightFuzzySet(0, 5, 3, 4)));
        system.addOutputVariable(zoom);

        WriteLine("2) Ajout des règles", true);

        // Création des règles selon la matrice suivante :
        // Plus le zoom est petit, plus on voit loin (mais moins détaillé)
        // V \ D  || F | M | G |
        // Lent   || N | P | P |
        // Peu Ra || N | N | P |
        // Rapide || G | N | P |
        // Très R || G | G | P |
        system.addFuzzyRule("IF Distance IS Grande THEN Zoom IS Petit");
        system.addFuzzyRule("IF Distance IS Faible AND Vitesse IS Lente THEN Zoom IS Normal");
        system.addFuzzyRule("IF Distance IS Faible AND Vitesse IS PeuRapide THEN Zoom IS Normal");
        system.addFuzzyRule("IF Distance IS Faible AND Vitesse IS Rapide THEN Zoom IS Gros");
        system.addFuzzyRule("IF Distance IS Faible AND Vitesse IS TresRapide THEN Zoom IS Gros");
        system.addFuzzyRule("IF Distance IS Moyenne AND Vitesse IS Lente THEN Zoom IS Petit");
        system.addFuzzyRule("IF Distance IS Moyenne AND Vitesse IS PeuRapide THEN Zoom IS Normal");
        system.addFuzzyRule("IF Distance IS Moyenne AND Vitesse IS Rapide THEN Zoom IS Normal");
        system.addFuzzyRule("IF Distance IS Moyenne AND Vitesse IS TresRapide THEN Zoom IS Gros");
        WriteLine("9 règles ajoutées \n");

        WriteLine("3) Résolution de cas pratiques", true);
        // Cas pratique 1 : vitesse de 35 kms/h, et prochain changement de direction à 70m
        WriteLine("Cas 1 :", true);
        WriteLine("V = 35 (peu rapide)");
        WriteLine("D = 70 (moyenne)");
        system.SetInputVariable(vitesse, 35);
        system.SetInputVariable(distance, 70);
        WriteLine("Attendu : zoom normal, centroïde à 2.5");
        WriteLine("Résultat : " + system.Solve() + "\n");

        // Cas pratique 2 : vitesse de 25 kms/h, et prochain changement de direction à 70m
        system.ResetCase();
        WriteLine("Cas 2 :", true);
        WriteLine("V = 25 (50% lente, 50% peu rapide)");
        WriteLine("D = 70 (moyenne)");
        system.SetInputVariable(vitesse, 25);
        system.SetInputVariable(distance, 70);
        WriteLine("Attendu : zoom normal à 50% + zoom petit à 50%");
        WriteLine("Résultat : " + system.Solve() + "\n");

        // Cas pratique 3 : vitesse de 72.5 kms/h, et prochain changement de direction à 40m
        system.ResetCase();
        WriteLine("Cas 3 :", true);
        WriteLine("V = 72.5 (75% peu rapide + 25% rapide)");
        WriteLine("D = 40 (50% faible)");
        system.SetInputVariable(vitesse, 72.5);
        system.SetInputVariable(distance, 40);
        WriteLine("Attendu : zoom normal à 50% + zoom gros à 25%");
        WriteLine("Résultat : " + system.Solve() + "\n");

        // Cas pratique 4 : vitesse de 100 kms/h, et prochain changement de direction à 110m
        system.ResetCase();
        WriteLine("Cas 4 :", true);
        WriteLine("V = 100 (50% rapide + 50% très rapide)");
        WriteLine("D = 110 (80% moyenne, 20% grande)");
        system.SetInputVariable(vitesse, 100);
        system.SetInputVariable(distance, 110);
        WriteLine("Attendu : zoom petit à 20% + zoom normal à 50% + zoom gros à 50%");
        WriteLine("Résultat : " + system.Solve() + "\n");

        // Cas pratique 5 : vitesse de 45 kms/h, et prochain changement de direction à 160m
        system.ResetCase();
        WriteLine("Cas 5 :", true);
        WriteLine("V = 45 (100% peu rapide)");
        WriteLine("D = 160 (100% grande)");
        system.SetInputVariable(vitesse, 45);
        system.SetInputVariable(distance, 160);
        WriteLine("Attendu : zoom petit à 100%");
        WriteLine("Résultat : " + system.Solve() + "\n");

        while (true)
        {
            ;
        }
    }