Example #1
0
        public Hunger() : base()
        {
            _module = new FuzzyModule();

            // Antecedents
            FuzzyVariable Hunger     = _module.CreateFLV("Hunger");
            var           Hunger_Low = Hunger.AddLeftShoulderSet("Hunger_Low", 0, 15, 30);
            var           Hunger_Med = Hunger.AddTriangularSet("Hunger_Med", 15, 30, 45);
            var           Hunger_Big = Hunger.AddRightShoulderSet("Hunger_Big", 30, 45, _MAX_HUNGER);

            FuzzyVariable Distance        = _module.CreateFLV("Distance");
            var           Distance_Close  = Distance.AddLeftShoulderSet("Distance_Close", 0, 40, 80);
            var           Distance_Medium = Distance.AddTriangularSet("Distance_Medium", 40, 80, 400);
            var           Distance_Far    = Distance.AddRightShoulderSet("Distance_Far", 80, 400, MAX_DISTANCE);

            // Consequence
            FuzzyVariable Desirability  = _module.CreateFLV("Desirability");
            var           Undesirable   = Desirability.AddLeftShoulderSet("Undesirable", 0, 25, 50);
            var           Desirable     = Desirability.AddTriangularSet("Desirable", 25, 50, 75);
            var           VeryDesirable = Desirability.AddRightShoulderSet("VeryDesirable", 50, 75, 100);

            // Rules
            _module.AddRule(new FzAND(Hunger_Low, Distance_Close), Undesirable);
            _module.AddRule(new FzAND(Hunger_Low, Distance_Medium), Undesirable);
            _module.AddRule(new FzAND(Hunger_Low, Distance_Far), Undesirable);
            _module.AddRule(new FzAND(Hunger_Med, Distance_Close), Desirable);
            _module.AddRule(new FzAND(Hunger_Med, Distance_Medium), Undesirable);
            _module.AddRule(new FzAND(Hunger_Med, Distance_Far), Undesirable);
            _module.AddRule(new FzAND(Hunger_Big, Distance_Close), VeryDesirable);
            _module.AddRule(new FzAND(Hunger_Big, Distance_Medium), VeryDesirable);
            _module.AddRule(new FzAND(Hunger_Big, Distance_Far), Desirable);
        }
Example #2
0
        public Sleep() : base()
        {
            _module = new FuzzyModule();

            // Antecedents
            FuzzyVariable Sleep      = _module.CreateFLV("Sleep");
            var           Sleep_Low  = Sleep.AddLeftShoulderSet("Sleep_Low", 0, 10, 20);
            var           Sleep_Med  = Sleep.AddTriangularSet("Sleep_Med", 10, 20, 30);
            var           Sleep_High = Sleep.AddRightShoulderSet("Sleep_High", 20, 30, _MAX_SLEEP);

            FuzzyVariable Distance        = _module.CreateFLV("Distance");
            var           Distance_Close  = Distance.AddLeftShoulderSet("Distance_Close", 0, 40, 80);
            var           Distance_Medium = Distance.AddTriangularSet("Distance_Medium", 40, 80, 400);
            var           Distance_Far    = Distance.AddRightShoulderSet("Distance_Far", 80, 400, MAX_DISTANCE);

            // Consequence
            FuzzyVariable Desirability  = _module.CreateFLV("Desirability");
            var           Undesirable   = Desirability.AddLeftShoulderSet("Undesirable", 0, 25, 50);
            var           Desirable     = Desirability.AddTriangularSet("Desirable", 25, 50, 75);
            var           VeryDesirable = Desirability.AddRightShoulderSet("VeryDesirable", 50, 75, 100);

            // Rules
            _module.AddRule(new FzAND(Sleep_Low, Distance_Close), Undesirable);
            _module.AddRule(new FzAND(Sleep_Low, Distance_Medium), Undesirable);
            _module.AddRule(new FzAND(Sleep_Low, Distance_Far), Undesirable);
            _module.AddRule(new FzAND(Sleep_Med, Distance_Close), Desirable);
            _module.AddRule(new FzAND(Sleep_Med, Distance_Medium), Desirable);
            _module.AddRule(new FzAND(Sleep_Med, Distance_Far), Undesirable);
            _module.AddRule(new FzAND(Sleep_High, Distance_Close), VeryDesirable);
            _module.AddRule(new FzAND(Sleep_High, Distance_Medium), VeryDesirable);
            _module.AddRule(new FzAND(Sleep_High, Distance_Far), Desirable);
        }