Пример #1
0
        private FuzzySystem GetModifiedFuzzySystem(ArrayList ActualParameters)
        {
            // Clone fuzzysystem
            FuzzySystem tempFuz = (FuzzySystem)Activator.CreateInstance(fuzzySystem.GetType());

            tempFuz.CopyDataFrom(fuzzySystem);

            /*FuzzySystem tempFuz = null;
             * switch (fuzzySystem.Type)
             * {
             *  case FuzzyType.Mamdani:
             *      tempFuz = new MamdaniFS();
             *      break;
             *  case FuzzyType.Larsen:
             *      tempFuz = new LarsenFS();
             *      break;
             *  case FuzzyType.Sugeno:
             *      tempFuz = new SugenoFS();
             *      break;
             *  case FuzzyType.Sparse:
             *  default:
             *      throw new NotImplementedException();
             *      break;
             * }*/

            // Read settings
            bool In  = false;
            bool Out = false;
            bool RP  = false;

            Dispatcher.Invoke(() =>
            {
                In  = CheckInput.IsChecked == true;
                Out = CheckOutput.IsChecked == true;
                RP  = RadioRefPoint.IsChecked == true;
            });

            // Store the number of MFs handled by the optimization
            int finishedMfCount = 0;

            if (In)
            {
                for (int inputId = 0; inputId < tempFuz.Inputs.Length; inputId++)
                {
                    for (int mfId = 0; mfId < tempFuz.Inputs[inputId].MFs.Length; mfId++)
                    {
                        if (RP)
                        {
                            tempFuz.Inputs[inputId].MFs[mfId] = tempFuz.Inputs[inputId].MFs[mfId].GetAtRefPoint(
                                (float)((double)ActualParameters[finishedMfCount + mfId]));
                        }
                        else
                        {
                            tempFuz.Inputs[inputId].MFs[mfId] = MembershipFunction.CreateTrapezoid(
                                tempFuz.Inputs[inputId].MFs[mfId].GetTrapReferencePoint(),
                                tempFuz.Inputs[inputId].MFs[mfId].GetTrapBottomBase(),
                                tempFuz.Inputs[inputId].MFs[mfId].GetTrapBottomBase() * (float)((double)ActualParameters[finishedMfCount + mfId]));
                        }
                    }
                    finishedMfCount += tempFuz.Inputs[inputId].NumMFs;
                }
            }
            if (Out)
            {
                for (int outputId = 0; outputId < tempFuz.Outputs.Length; outputId++)
                {
                    for (int mfId = 0; mfId < tempFuz.Outputs[outputId].MFs.Length; mfId++)
                    {
                        if (RP)
                        {
                            tempFuz.Outputs[outputId].MFs[mfId] = tempFuz.Outputs[outputId].MFs[mfId].GetAtRefPoint(
                                (float)((double)ActualParameters[finishedMfCount + mfId]));
                        }
                        else
                        {
                            tempFuz.Outputs[outputId].MFs[mfId] = MembershipFunction.CreateTrapezoid(
                                tempFuz.Outputs[outputId].MFs[mfId].GetTrapReferencePoint(),
                                tempFuz.Outputs[outputId].MFs[mfId].GetTrapBottomBase(),
                                tempFuz.Outputs[outputId].MFs[mfId].GetTrapBottomBase() * (float)((double)ActualParameters[finishedMfCount + mfId]));
                        }
                    }
                    finishedMfCount += tempFuz.Outputs[outputId].NumMFs;
                }
            }

            return(tempFuz);
        }