Esempio n. 1
0
        public int GetPeopleCountForEnergy(double energyval)
        {
            if (energyval > 10000)
            {
                // return heating energy?
                return(5);
            }

            var energy = _fsTips.InputByName("energy");
            //FuzzyVariable fvFood = fsTips.InputByName("food");
            var people = _fsTips.OutputByName("people");

            //
            // Associate input values with input variables
            //

            var inputValues = new Dictionary <FuzzyVariable, double> {
                { energy, energyval }
            };

            var result = _fsTips.Calculate(inputValues);

            //_logger.Info(i + ": " + result[people].ToString("f1"));
            var resultval = Math.Round(result[people]);

            if (double.IsNaN(resultval))
            {
                return(5);
            }

            return((int)resultval);
        }
Esempio n. 2
0
        public string CreateFuzzyRuleAndReturnResult(FetchRuleDTO rules, double inputValue)
        {
            FuzzySystemResultDTO system = new FuzzySystemResultDTO();

            system     = CreateSystem(rules, inputValue);
            _fsGround  = system.System;
            inputValue = system.InputValue;


            FuzzyVariable fvInput  = _fsGround.InputByName(rules.VariableList.FirstOrDefault(d => d.variableTypeID == (byte)Enums.VariableType.Input).visibleVariableName);
            FuzzyVariable fvOutput = _fsGround.OutputByName(rules.VariableList.FirstOrDefault(d => d.variableTypeID == (byte)Enums.VariableType.Output).visibleVariableName);

            Dictionary <FuzzyVariable, double> inputValues = new Dictionary <FuzzyVariable, double>();

            inputValues.Add(fvInput, inputValue);

            Dictionary <FuzzyVariable, double> result = _fsGround.Calculate(inputValues);

            _fsGround.DefuzzificationMethod = DefuzzificationMethod.Centroid;

            double outputValue = result[fvOutput];
            string outputType  = ReturnLimitNearbyResults(rules, outputValue);

            return(outputType);
        }
Esempio n. 3
0
        public void CalculateFuzzy(List <Actor> ownUnits, List <Actor> enemyUnits)
        {
            Dictionary <FuzzyVariable, double> inputValues = new Dictionary <FuzzyVariable, double>();

            inputValues.Add(fuzzyEngine.InputByName("OwnHealth"), (double)NormalizedHealth(ownUnits, 100));
            inputValues.Add(fuzzyEngine.InputByName("EnemyHealth"), (double)NormalizedHealth(enemyUnits, 100));
            inputValues.Add(fuzzyEngine.InputByName("RelativeAttackPower"), (double)RelativePower(ownUnits, enemyUnits));
            inputValues.Add(fuzzyEngine.InputByName("RelativeSpeed"), (double)RelativeSpeed(ownUnits, enemyUnits));

            result = fuzzyEngine.Calculate(inputValues);
        }
Esempio n. 4
0
        public bool CanAttack(IEnumerable <Actor> ownUnits, IEnumerable <Actor> enemyUnits)
        {
            var inputValues = new Dictionary <FuzzyVariable, double>();

            inputValues.Add(fuzzyEngine.InputByName("OwnHealth"), (double)NormalizedHealth(ownUnits, 100));
            inputValues.Add(fuzzyEngine.InputByName("EnemyHealth"), (double)NormalizedHealth(enemyUnits, 100));
            inputValues.Add(fuzzyEngine.InputByName("RelativeAttackPower"), (double)RelativePower(ownUnits, enemyUnits));
            inputValues.Add(fuzzyEngine.InputByName("RelativeSpeed"), (double)RelativeSpeed(ownUnits, enemyUnits));

            var result       = fuzzyEngine.Calculate(inputValues);
            var attackChance = result[fuzzyEngine.OutputByName("AttackOrFlee")];

            return(!double.IsNaN(attackChance) && attackChance < 30.0);
        }
Esempio n. 5
0
        public double obtenerCostoCalidad()
        {
            if (_fsCostoCalidad == null)
            {
                _fsCostoCalidad = CrearSistemaCostoCalidad();
                if (_fsCostoCalidad == null)
                {
                    return(-1);
                }
            }

            FuzzyVariable fvCalidadProducto = _fsCostoCalidad.InputByName("calidad_producto");
            FuzzyVariable fvCostoTotal      = _fsCostoCalidad.InputByName("costo_total");


            FuzzyVariable fvPuntajeSoftware = _fsCostoCalidad.OutputByName("puntaje_software");



            //
            // Associate input values with input variables
            //
            Dictionary <FuzzyVariable, double> inputValues = new Dictionary <FuzzyVariable, double>();

            inputValues.Add(fvCalidadProducto, this.valorCalidadProducto);
            inputValues.Add(fvCostoTotal, this.valorCostoTotal);

            //
            // Calculate result: one output value for each output variable
            //
            Dictionary <FuzzyVariable, double> result = _fsCostoCalidad.Calculate(inputValues);

            //
            // Get output value for the 'tips' variable
            //
            if (result[fvPuntajeSoftware].ToString("f1").Equals("NeuN"))
            {
                Console.WriteLine("ESTA MALO EL VALOR DE PUNTAJE DE SOFTWARE");
                return(-1);
            }
            else
            {
                return(result[fvPuntajeSoftware]);
            }
        }
Esempio n. 6
0
        public bool FuzzyGenerateRulesAndGetResultFLLComparison(GetRuleDTO rules, double inputValue1, double inputValue2, int rate)
        {
            FuzzySystemResultDTO system = new FuzzySystemResultDTO();

            system      = GenerateSystem(rules, inputValue1);
            _fsSoil     = system.System;
            inputValue1 = system.InputValue;

            FuzzyVariable fvInput1  = _fsSoil.InputByName(rules.VariableList.FirstOrDefault(d => d.DegiskenTipID == (byte)Enums.VariableType.Input).DegiskenGorunenAdi);
            FuzzyVariable fvOutput1 = _fsSoil.OutputByName(rules.VariableList.FirstOrDefault(d => d.DegiskenTipID == (byte)Enums.VariableType.Output).DegiskenGorunenAdi);

            Dictionary <FuzzyVariable, double> inputValues1 = new Dictionary <FuzzyVariable, double>();

            inputValues1.Add(fvInput1, inputValue1);

            Dictionary <FuzzyVariable, double> result1 = _fsSoil.Calculate(inputValues1);

            _fsSoil.DefuzzificationMethod = DefuzzificationMethod.Bisector;

            double outputValue1 = result1[fvOutput1];

            _fsSoil     = null;
            system      = GenerateSystem(rules, inputValue2);
            _fsSoil     = system.System;
            inputValue2 = system.InputValue;

            FuzzyVariable fvInput2  = _fsSoil.InputByName(rules.VariableList.FirstOrDefault(d => d.DegiskenTipID == (byte)Enums.VariableType.Input).DegiskenGorunenAdi);
            FuzzyVariable fvOutput2 = _fsSoil.OutputByName(rules.VariableList.FirstOrDefault(d => d.DegiskenTipID == (byte)Enums.VariableType.Output).DegiskenGorunenAdi);

            Dictionary <FuzzyVariable, double> inputValues2 = new Dictionary <FuzzyVariable, double>();

            inputValues2.Add(fvInput2, inputValue2);

            Dictionary <FuzzyVariable, double> result2 = _fsSoil.Calculate(inputValues2);

            _fsSoil.DefuzzificationMethod = DefuzzificationMethod.Centroid;

            double outputValue2 = result2[fvOutput2];

            var result = GetResultForProximity(outputValue1, outputValue2, rate);

            return(result);
        }
Esempio n. 7
0
        public bool CreateFuzzyRuleAndCompare(FetchRuleDTO rules, double inputValue1, double inputValue2, int ratio)
        {
            FuzzySystemResultDTO system = new FuzzySystemResultDTO();

            system      = CreateSystem(rules, inputValue1);
            _fsGround   = system.System;
            inputValue1 = system.InputValue;

            FuzzyVariable fvInput1  = _fsGround.InputByName(session.variables.FirstOrDefault(d => d.variableTypeID == (byte)Enums.VariableType.Input).visibleVariableName);
            FuzzyVariable fvOutput1 = _fsGround.OutputByName(session.variables.FirstOrDefault(d => d.variableTypeID == (byte)Enums.VariableType.Output).visibleVariableName);

            Dictionary <FuzzyVariable, double> inputValues1 = new Dictionary <FuzzyVariable, double>();

            inputValues1.Add(fvInput1, inputValue1);

            Dictionary <FuzzyVariable, double> result1 = _fsGround.Calculate(inputValues1);

            _fsGround.DefuzzificationMethod = DefuzzificationMethod.Bisector;

            double outputValue1 = result1[fvOutput1];

            _fsGround   = null;
            system      = CreateSystem(rules, inputValue2);
            _fsGround   = system.System;
            inputValue2 = system.InputValue;

            FuzzyVariable fvInput2  = _fsGround.InputByName(rules.VariableList.FirstOrDefault(d => d.variableTypeID == (byte)Enums.VariableType.Input).visibleVariableName);
            FuzzyVariable fvOutput2 = _fsGround.OutputByName(rules.VariableList.FirstOrDefault(d => d.variableTypeID == (byte)Enums.VariableType.Output).visibleVariableName);

            Dictionary <FuzzyVariable, double> inputValues2 = new Dictionary <FuzzyVariable, double>();

            inputValues2.Add(fvInput2, inputValue2);

            Dictionary <FuzzyVariable, double> result2 = _fsGround.Calculate(inputValues2);

            _fsGround.DefuzzificationMethod = DefuzzificationMethod.Centroid;

            double outputValue2 = result2[fvOutput2];

            var result = ReturnNearbyResults(outputValue1, outputValue2, ratio);

            return(result);
        }
Esempio n. 8
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            //
            // Create new fuzzy system
            //
            if (_fsTips == null)
            {
                _fsTips = CreateSystem();
                if (_fsTips == null)
                {
                    return;
                }
            }

            //
            // Get variables from the system (for convinience only)
            //
            FuzzyVariable fvService = _fsTips.InputByName("service");
            FuzzyVariable fvFood    = _fsTips.InputByName("food");
            FuzzyVariable fvTips    = _fsTips.OutputByName("tips");

            //
            // Associate input values with input variables
            //
            Dictionary <FuzzyVariable, double> inputValues = new Dictionary <FuzzyVariable, double>();

            inputValues.Add(fvService, (double)nudInputService.Value);
            inputValues.Add(fvFood, (double)nudInputFood.Value);

            //
            // Calculate result: one output value for each output variable
            //
            Dictionary <FuzzyVariable, double> result = _fsTips.Calculate(inputValues);

            //
            // Get output value for the 'tips' variable
            //
            tbTips.Text = result[fvTips].ToString("f1");
        }
Esempio n. 9
0
        public static Dictionary <NodeInstance, double> PrioritizeNodes(List <NodeInstance> nodes)
        {
            MamdaniFuzzySystem fsNodeSys = new MamdaniFuzzySystem();

            FuzzyVariable fvCPU = new FuzzyVariable("cpu", 0.0, 1);

            fvCPU.Terms.Add(new FuzzyTerm("low", new TriangularMembershipFunction(-.50, 0, .50)));
            fvCPU.Terms.Add(new FuzzyTerm("med", new TriangularMembershipFunction(0, .50, 1)));
            fvCPU.Terms.Add(new FuzzyTerm("high", new TriangularMembershipFunction(.50, 1, 1.5)));
            fsNodeSys.Input.Add(fvCPU);

            FuzzyVariable fvBandwidth = new FuzzyVariable("bandwidth", 0.0, 1);

            fvBandwidth.Terms.Add(new FuzzyTerm("low", new TriangularMembershipFunction(-.50, 0, .50)));
            fvBandwidth.Terms.Add(new FuzzyTerm("med", new TriangularMembershipFunction(0, .50, 1)));
            fvBandwidth.Terms.Add(new FuzzyTerm("high", new TriangularMembershipFunction(.50, 1, 1.5)));
            fsNodeSys.Input.Add(fvBandwidth);

            FuzzyVariable fvFreeSpace = new FuzzyVariable("freespace", 0.0, 1);

            fvFreeSpace.Terms.Add(new FuzzyTerm("low", new TriangularMembershipFunction(-.5, 0, .5)));
            fvFreeSpace.Terms.Add(new FuzzyTerm("moderate", new TriangularMembershipFunction(0, .5, 1)));
            fvFreeSpace.Terms.Add(new FuzzyTerm("ample", new TriangularMembershipFunction(.5, 1, 1.5)));
            fsNodeSys.Input.Add(fvFreeSpace);

            //
            // Create output variables for the system
            //
            FuzzyVariable fvRank = new FuzzyVariable("rank", 0, 1);

            fvRank.Terms.Add(new FuzzyTerm("low", new TriangularMembershipFunction(-0.25, 0, 0.25)));
            fvRank.Terms.Add(new FuzzyTerm("med_low", new TriangularMembershipFunction(0, 0.25, 0.50)));
            fvRank.Terms.Add(new FuzzyTerm("med", new TriangularMembershipFunction(0.25, 0.50, 0.75)));
            fvRank.Terms.Add(new FuzzyTerm("med_high", new TriangularMembershipFunction(0.50, 0.75, 1)));
            fvRank.Terms.Add(new FuzzyTerm("high", new TriangularMembershipFunction(0.75, 1, 1.25)));

            fsNodeSys.Output.Add(fvRank);

            MamdaniFuzzyRule rule1  = fsNodeSys.ParseRule("if (cpu is low) and (bandwidth is high) and (freespace is ample) then rank is med");
            MamdaniFuzzyRule rule2  = fsNodeSys.ParseRule("if (cpu is low) and (bandwidth is high) and (freespace is moderate) then rank is med_low");
            MamdaniFuzzyRule rule3  = fsNodeSys.ParseRule("if (cpu is low) and (bandwidth is high) and (freespace is low) then rank is low");
            MamdaniFuzzyRule rule4  = fsNodeSys.ParseRule("if (cpu is low) and (bandwidth is med) and (freespace is ample) then rank is med_high");
            MamdaniFuzzyRule rule5  = fsNodeSys.ParseRule("if (cpu is low) and (bandwidth is med) and (freespace is moderate) then rank is med_high");
            MamdaniFuzzyRule rule6  = fsNodeSys.ParseRule("if (cpu is low) and (bandwidth is med) and (freespace is low) then rank is med_low");
            MamdaniFuzzyRule rule7  = fsNodeSys.ParseRule("if (cpu is low) and (bandwidth is low) and (freespace is ample) then rank is high");
            MamdaniFuzzyRule rule8  = fsNodeSys.ParseRule("if (cpu is low) and (bandwidth is low) and (freespace is moderate) then rank is med_high");
            MamdaniFuzzyRule rule9  = fsNodeSys.ParseRule("if (cpu is low) and (bandwidth is low) and (freespace is low) then rank is med_low");
            MamdaniFuzzyRule rule10 = fsNodeSys.ParseRule("if (cpu is med) and (bandwidth is high) and (freespace is ample) then rank is med");
            MamdaniFuzzyRule rule11 = fsNodeSys.ParseRule("if (cpu is med) and (bandwidth is high) and (freespace is moderate) then rank is med_low");
            MamdaniFuzzyRule rule12 = fsNodeSys.ParseRule("if (cpu is med) and (bandwidth is high) and (freespace is low) then rank is med_low");
            MamdaniFuzzyRule rule13 = fsNodeSys.ParseRule("if (cpu is med) and (bandwidth is med) and (freespace is ample) then rank is med");
            MamdaniFuzzyRule rule14 = fsNodeSys.ParseRule("if (cpu is med) and (bandwidth is med) and (freespace is moderate) then rank is med");
            MamdaniFuzzyRule rule15 = fsNodeSys.ParseRule("if (cpu is med) and (bandwidth is med) and (freespace is low) then rank is low");
            MamdaniFuzzyRule rule16 = fsNodeSys.ParseRule("if (cpu is med) and (bandwidth is low) and (freespace is ample) then rank is med_high");
            MamdaniFuzzyRule rule17 = fsNodeSys.ParseRule("if (cpu is med) and (bandwidth is low) and (freespace is moderate) then rank is med_high");
            MamdaniFuzzyRule rule18 = fsNodeSys.ParseRule("if (cpu is med) and (bandwidth is low) and (freespace is low) then rank is low");
            MamdaniFuzzyRule rule19 = fsNodeSys.ParseRule("if (cpu is high) and (bandwidth is high) and (freespace is ample) then rank is med");
            MamdaniFuzzyRule rule20 = fsNodeSys.ParseRule("if (cpu is high) and (bandwidth is high) and (freespace is moderate) then rank is med_low");
            MamdaniFuzzyRule rule21 = fsNodeSys.ParseRule("if (cpu is high) and (bandwidth is high) and (freespace is low) then rank is low");
            MamdaniFuzzyRule rule22 = fsNodeSys.ParseRule("if (cpu is high) and (bandwidth is med) and (freespace is ample) then rank is med");
            MamdaniFuzzyRule rule23 = fsNodeSys.ParseRule("if (cpu is high) and (bandwidth is med) and (freespace is moderate) then rank is med_low");
            MamdaniFuzzyRule rule24 = fsNodeSys.ParseRule("if (cpu is high) and (bandwidth is med) and (freespace is low) then rank is low");
            MamdaniFuzzyRule rule25 = fsNodeSys.ParseRule("if (cpu is high) and (bandwidth is low) and (freespace is ample) then rank is med_low");
            MamdaniFuzzyRule rule26 = fsNodeSys.ParseRule("if (cpu is high) and (bandwidth is low) and (freespace is moderate) then rank is med");
            MamdaniFuzzyRule rule27 = fsNodeSys.ParseRule("if (cpu is high) and (bandwidth is low) and (freespace is low) then rank is low");

            fsNodeSys.Rules.Add(rule1);
            fsNodeSys.Rules.Add(rule2);
            fsNodeSys.Rules.Add(rule3);
            fsNodeSys.Rules.Add(rule4);
            fsNodeSys.Rules.Add(rule5);
            fsNodeSys.Rules.Add(rule6);
            fsNodeSys.Rules.Add(rule7);
            fsNodeSys.Rules.Add(rule8);
            fsNodeSys.Rules.Add(rule9);
            fsNodeSys.Rules.Add(rule10);
            fsNodeSys.Rules.Add(rule11);
            fsNodeSys.Rules.Add(rule12);
            fsNodeSys.Rules.Add(rule13);
            fsNodeSys.Rules.Add(rule14);
            fsNodeSys.Rules.Add(rule15);
            fsNodeSys.Rules.Add(rule16);
            fsNodeSys.Rules.Add(rule17);
            fsNodeSys.Rules.Add(rule18);
            fsNodeSys.Rules.Add(rule19);
            fsNodeSys.Rules.Add(rule20);
            fsNodeSys.Rules.Add(rule21);
            fsNodeSys.Rules.Add(rule22);
            fsNodeSys.Rules.Add(rule23);
            fsNodeSys.Rules.Add(rule24);
            fsNodeSys.Rules.Add(rule25);
            fsNodeSys.Rules.Add(rule26);
            fsNodeSys.Rules.Add(rule27);

            var rankedNodes = new Dictionary <NodeInstance, double>();

            for (int i = 0; i < nodes.Count; i++)
            {
                //
                // Fuzzify input values
                //
                Dictionary <FuzzyVariable, double> inputValues = new Dictionary <FuzzyVariable, double>();
                inputValues.Add(fvCPU, nodes[i].CPU_Utilization);
                inputValues.Add(fvBandwidth, nodes[i].UsedBandwidth / nodes[i].MaxBandwidth);
                inputValues.Add(fvFreeSpace, nodes[i].FreeSpace / nodes[i].MaxBackupSpace);

                //
                // Calculate the result
                //
                Dictionary <FuzzyVariable, double> result = fsNodeSys.Calculate(inputValues);

                double rank = result[fvRank];
                rankedNodes.Add(nodes[i], rank);

                //Console.WriteLine(nodes[i].ToString());
                //Console.WriteLine("Rank: " + Math.Round(rank, 2).ToString());
                //Console.WriteLine();
            }
            var sortedNodes
                = (from entry in rankedNodes orderby entry.Value descending select entry)
                  .ToDictionary(pair => pair.Key, pair => pair.Value);

            return(sortedNodes);
        }
Esempio n. 10
0
        public string FuzzyGenerateRulesAndGetResultFLL(GetRuleDTO rules, double inputValue)
        {
            //var ozdirenc = GorunenAdDuzenle(kuralKume.OzdirencList);
            //var toprak = GorunenAdDuzenle(kuralKume.ToprakList);
            FuzzySystemResultDTO system = new FuzzySystemResultDTO();

            system     = GenerateSystem(rules, inputValue);
            _fsSoil    = system.System;
            inputValue = system.InputValue;


            FuzzyVariable fvInput  = _fsSoil.InputByName(rules.VariableList.FirstOrDefault(d => d.DegiskenTipID == (byte)Enums.VariableType.Input).DegiskenGorunenAdi);
            FuzzyVariable fvOutput = _fsSoil.OutputByName(rules.VariableList.FirstOrDefault(d => d.DegiskenTipID == (byte)Enums.VariableType.Output).DegiskenGorunenAdi);

            Dictionary <FuzzyVariable, double> inputValues = new Dictionary <FuzzyVariable, double>();

            inputValues.Add(fvInput, inputValue);

            Dictionary <FuzzyVariable, double> result = _fsSoil.Calculate(inputValues);

            _fsSoil.DefuzzificationMethod = DefuzzificationMethod.Centroid;

            double outputValue = result[fvOutput];
            string outputType  = GetResultForCloseLine(rules, outputValue);

            return(outputType);

            #region FuzzyIslemleri
            //#region Inputs
            //FuzzyVariable fvOzdirenc = new FuzzyVariable("Ozdirenc", 0.0, 1000.0);
            //foreach (var item in ozdirenc)
            //{
            //    fvOzdirenc.Terms.Add(new FuzzyTerm(item.Adi, new TriangularMembershipFunction(item.MinDeger, (item.MinDeger + item.MaxDeger) / 2, item.MaxDeger)));
            //}
            //fsToprak.Input.Add(fvOzdirenc);

            //FuzzyVariable fvMukavemet = new FuzzyVariable("Mukavemet", 0.0, 1000.0);
            //foreach (var item in _commonManager.Mukavemet)
            //{
            //    fvMukavemet.Terms.Add(new FuzzyTerm(item.Adi, new TriangularMembershipFunction(item.MinDeger, (item.MinDeger + item.MaxDeger) / 2, item.MaxDeger)));
            //}
            //fsToprak.Input.Add(fvMukavemet);

            //FuzzyVariable fvDoygunluk = new FuzzyVariable("Doygunluk", 0.0, 10.0);
            //foreach (var item in _commonManager.Doygunluk)
            //{
            //    fvDoygunluk.Terms.Add(new FuzzyTerm(item.Adi, new TriangularMembershipFunction(item.MinDeger, (item.MinDeger + item.MaxDeger) / 2, item.MaxDeger)));
            //}
            //fsToprak.Input.Add(fvDoygunluk);
            //#endregion

            //#region Output
            //FuzzyVariable fvToprak = new FuzzyVariable("Toprak", 0.0, 1000.0);
            //foreach (var item in toprak)
            //{
            //    fvToprak.Terms.Add(new FuzzyTerm(item.Adi, new TriangularMembershipFunction(item.MinDeger, (item.MinDeger + item.MaxDeger) / 2, item.MaxDeger)));
            //}
            //fsToprak.Output.Add(fvToprak);
            //#endregion
            //List<string> kurallar = new List<string>();

            //foreach (var KuralListItem in kuralKume.KuralList)
            //{
            //    string ruleText = KuralOlustur(KuralListItem) + " then (Toprak is " + KuralListItem.Sonuc + ")";
            //    kurallar.Add(ruleText);
            //}
            #endregion
        }
Esempio n. 11
0
    void chooseTargetLocation()
    {
        FuzzyVariable fvHunger    = _fsAstronaut.InputByName("Hunger");
        FuzzyVariable fvThirst    = _fsAstronaut.InputByName("Thirst");
        FuzzyVariable fvTiredness = _fsAstronaut.InputByName("Tiredness");
        FuzzyVariable svTarget    = _fsAstronaut.OutputByName("Target");

        Dictionary <FuzzyVariable, double> inputValues = new Dictionary <FuzzyVariable, double>();

        inputValues.Add(fvHunger, _stats.Hungry);
        inputValues.Add(fvThirst, _stats.Thirsty);
        inputValues.Add(fvTiredness, _stats.Tiredness);

        targetLocation = null;
        Dictionary <FuzzyVariable, double> result = _fsAstronaut.Calculate(inputValues);

        Debug.Log("fuzzy result: " + result[svTarget]);
        if (targetLocation == null && result[svTarget] >= 0.0f && result[svTarget] < 0.3f)
        {
            Debug.Log("I WANT TO GO TO RESIDENTIAL AREA");
            targetLocation = getModuleIfNotOccupied(ModuleType.ResidentalBay);
            if (null != targetLocation)
            {
                if (_stats.Tiredness < 0.3)
                {
                    Debug.Log("I WANT TO REST THERE");
                    timeTargetSpentInArea = restCycle;
                }
                else if (_stats.Tiredness < 0.6)
                {
                    Debug.Log("I WANT TO NAP THERE");
                    timeTargetSpentInArea = napCycle;
                }
                else
                {
                    Debug.Log("I WANT TO SLEEP THERE");
                    timeTargetSpentInArea = sleepCycle;
                }
            }
        }
        if (targetLocation == null && result[svTarget] >= 0.3f && result[svTarget] < 0.6f)
        {
            Debug.Log("I WANT TO GO TO CANTEEN");
            targetLocation = getModuleIfNotOccupied(ModuleType.Canteen);
            if (null != targetLocation)
            {
                timeTargetSpentInArea = hungerCanteenPerSecond * 100;
            }
        }
        if (targetLocation == null && result[svTarget] >= 0.6f)
        {
            Debug.Log("I WANT TO GO WORK");
            System.Random rnd = new System.Random();
            if ((float)rnd.NextDouble() >= 0.5f)
            {
                targetLocation = getModuleIfNotOccupied(ModuleType.Greenhouse);
                if (null != targetLocation)
                {
                    timeTargetSpentInArea = tirednessGreenhousePerSecond * 300;
                }
            }
            else
            {
                targetLocation = getModuleIfNotOccupied(ModuleType.Gym);
                if (null != targetLocation)
                {
                    timeTargetSpentInArea = tirednessGymPerSecond * 200;
                }
            }
        }
    }