Esempio n. 1
0
        private void CalculateButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FuzzySystem fuzzy = FuzzyReader.GetFuzzySystemFromFile(FuzzySystemText.Text);
                fuzzy.LoadInputsAndSaveOutputs(InputValuesText.Text, "FuzzySystemTemporaryTestOutputFile.temp.del");
                float MSE = FuzzySystem.GetOutputFilesMSE(OutputValuesText.Text, "FuzzySystemTemporaryTestOutputFile.temp.del");
                if (File.Exists("FuzzySystemTemporaryTestOutputFile.temp.del"))
                {
                    File.Delete("FuzzySystemTemporaryTestOutputFile.temp.del");
                }

                MSEText.Text   = MSE.ToString(CultureInfo.InvariantCulture);
                RMSEText.Text  = Math.Sqrt(MSE).ToString(CultureInfo.InvariantCulture);
                RMSEPText.Text = (Math.Sqrt(MSE) / (fuzzy.Outputs[0].Range[1] - fuzzy.Outputs[0].Range[0]) * 100.0f).ToString(CultureInfo.InvariantCulture);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                if (File.Exists("FuzzySystemTemporaryTestOutputFile.temp.del"))
                {
                    File.Delete("FuzzySystemTemporaryTestOutputFile.temp.del");
                }
                return;
            }
        }
Esempio n. 2
0
    static void Main(string[] args)
    {
        FuzzyReader   reader = new FuzzyReader("FLC.txt");
        ControleFuzzy teste1 = reader.setFuzzySystem();

        Console.WriteLine("Input life");
        teste1.Fuzzification(teste1.GetVarFuzzy("life"), 30.1f);
        Console.WriteLine("Input damage");
        teste1.Fuzzification(teste1.GetVarFuzzy("damage"), 30.1f);
        Console.WriteLine("Input tempo");
        teste1.Fuzzification(teste1.GetVarFuzzy("time"), 30f);

        teste1.FuzzyInference();
        teste1.GetDefuzzification();
    }
Esempio n. 3
0
        public void LoadFuzzyFile(string FileName)
        {
            StreamReader reader = new StreamReader(FileName);

            FuzzyBox.Text = reader.ReadToEnd();
            reader.Close();

            SaveButton.IsEnabled = true;
            UseButton.IsEnabled  = true;

            //fuzzySystem = new FuzzySystem();
            try
            {
                fuzzySystem = FuzzyReader.GetFuzzySystemFromFile(FileName);
            }
            catch (Exception exc)
            {
                fuzzySystem = null;
                MessageBox.Show("Failed to load fuzzy system.\r\n" + (exc != null ? exc.Message : ""), "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            StringReader strRead = new StringReader(FuzzyBox.Text);
            string       str     = "";

            while ((str = strRead.ReadLine()) != null)
            {
                if (str.StartsWith("MF"))
                {
                    if (str.Contains("!"))
                    {
                        IncludeValuesCheckBox.IsChecked = true;
                    }
                    else
                    {
                        IncludeValuesCheckBox.IsChecked = false;
                    }
                    break;
                }
            }
            strRead.Close();

            CheckPreparation(null, null);
        }