コード例 #1
0
/*
 *              public static void LoadRedefinedMemberFunctions( Fuzzifier fuzzifier, string file )
 *              {
 *                      try
 *                      {
 * //				fuzzifier.m_MembershipFunctions.Clear();
 *
 *                              StreamReader reader = new StreamReader( file );
 *                              string line;
 *                              char[] separator = {' ', '\t', '\n'};
 *                              string[] tokens;
 *                              while ( ( line = reader.ReadLine() ) != null )
 *                              {
 *                                      line = line.Trim();
 *                                      if ( line.Length > 0 && line[0] != ';' )
 *                                      {
 *                                              tokens = line.Split( separator );
 *                                              MfInterface[] memberFuncToWrap = fuzzifier.GetMembershipFunctions( tokens[1] );
 *
 *                                              for ( int i = 0; i < memberFuncToWrap.Length; i++ )
 *                                              {
 *                                                      MfInterface wrapperMf = new RedefinedMemberFunction( tokens[0], memberFuncToWrap[i] );
 *                                                      fuzzifier.AddMembershipFunction( wrapperMf );
 *                                              }
 *                                      }
 *                              }
 *                              reader.Close();
 *                      }
 *                      catch ( Exception e )
 *                      {
 *                              LogWriter.Write( e.ToString() );
 *                      }
 *              }
 */

        public static void SaveMemberFunctions(Fuzzifier fuzzifier, string file)
        {
            try
            {
                StreamWriter writer = new StreamWriter(file, false);

                IDictionaryEnumerator htEnumerator = fuzzifier.m_MembershipFunctions.GetEnumerator();
                while (htEnumerator.MoveNext())
                {
                    ArrayList currentFunctions = ( ArrayList )htEnumerator.Value;
                    for (int i = 0; i < currentFunctions.Count; i++)
                    {
                        string      locked           = "";
                        MfInterface memberFuncToSave = ( MfInterface )currentFunctions[i];

                        if (memberFuncToSave.IsLocked())
                        {
                            locked = " *";
                        }

                        if (memberFuncToSave.SaveAble())
                        {
                            writer.WriteLine(memberFuncToSave.VariableName() + " " + memberFuncToSave.TermName() + " " + memberFuncToSave.BaseLeft() + " " + memberFuncToSave.CenterMax() + " " + memberFuncToSave.BaseRight() + locked);
                        }
                    }
                }
                writer.Close();
            }
            catch (Exception)
            {}
        }
コード例 #2
0
        public static void MakeReady(Fuzzifier fuzzifier)
        {
            fuzzifier.m_MembershipFunctions.Clear();

            string line;

            char[]   separator = { ' ', '\t', '\n' };
            string[] tokens;
            string[] s = MemberFunctionGrapper.GetFunctions();
            for (int i = 0; i < s.Length; i++)
            {
                line = s[i].Trim();
                if (line.Length > 0 && line[0] != ';')
                {
                    tokens = line.Split(separator);
                    MfInterface memberFunc = new MembershipFunction(tokens[0], tokens[1], double.Parse(tokens[2]), double.Parse(tokens[3]), double.Parse(tokens[4]));

                    if (tokens.Length > 5 && tokens[5].Equals("*"))
                    {
                        memberFunc.Lock(true);
                    }

                    fuzzifier.AddMembershipFunction(memberFunc);
                }
            }
        }
コード例 #3
0
ファイル: FuzzyController.cs プロジェクト: prezz/Fuzzy-Gammon
        public FuzzyController()
        {
            m_PreProcessor = new PreProcessor();
            PreProcessor.MakeReady( m_PreProcessor );

            m_Fuzzifier = new Fuzzifier();
            Fuzzifier.MakeReady( m_Fuzzifier );
            Fuzzifier.LoadMemberFunctions( m_Fuzzifier, ".\\Fuzzeval.mf" );

            m_InferenceEngine = new InferenceEngine();
            InferenceEngine.MakeReady( m_InferenceEngine );

            m_Defuzzifier = new Defuzzifier();
            Defuzzifier.MakeReady( m_Defuzzifier );
        }
コード例 #4
0
        public FuzzyController()
        {
            m_PreProcessor = new PreProcessor();
            PreProcessor.MakeReady(m_PreProcessor);

            m_Fuzzifier = new Fuzzifier();
            Fuzzifier.MakeReady(m_Fuzzifier);
            Fuzzifier.LoadMemberFunctions(m_Fuzzifier, ".\\Fuzzeval.mf");

            m_InferenceEngine = new InferenceEngine();
            InferenceEngine.MakeReady(m_InferenceEngine);

            m_Defuzzifier = new Defuzzifier();
            Defuzzifier.MakeReady(m_Defuzzifier);
        }
コード例 #5
0
        public static void LoadMemberFunctions(Fuzzifier fuzzifier, string file)
        {
            try
            {
                if (File.Exists(file))
                {
                    fuzzifier.m_MembershipFunctions.Clear();

                    StreamReader reader = new StreamReader(file);
                    string       line;
                    char[]       separator = { ' ', '\t', '\n' };
                    string[]     tokens;
                    while ((line = reader.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line.Length > 0 && line[0] != ';')
                        {
                            tokens = line.Split(separator);
                            MfInterface memberFunc = new MembershipFunction(tokens[0], tokens[1], double.Parse(tokens[2]), double.Parse(tokens[3]), double.Parse(tokens[4]));

                            if (tokens.Length > 5 && tokens[5].Equals("*"))
                            {
                                memberFunc.Lock(true);
                            }

                            fuzzifier.AddMembershipFunction(memberFunc);
                        }
                    }
                    reader.Close();
                }
            }
            catch (Exception e)
            {
                LogWriter.Write(e.ToString());
            }
        }
コード例 #6
0
ファイル: Fuzzifier.cs プロジェクト: prezz/Fuzzy-Gammon
        /*
        public static void LoadRedefinedMemberFunctions( Fuzzifier fuzzifier, string file )
        {
            try
            {
        //				fuzzifier.m_MembershipFunctions.Clear();

                StreamReader reader = new StreamReader( file );
                string line;
                char[] separator = {' ', '\t', '\n'};
                string[] tokens;
                while ( ( line = reader.ReadLine() ) != null )
                {
                    line = line.Trim();
                    if ( line.Length > 0 && line[0] != ';' )
                    {
                        tokens = line.Split( separator );
                        MfInterface[] memberFuncToWrap = fuzzifier.GetMembershipFunctions( tokens[1] );

                        for ( int i = 0; i < memberFuncToWrap.Length; i++ )
                        {
                            MfInterface wrapperMf = new RedefinedMemberFunction( tokens[0], memberFuncToWrap[i] );
                            fuzzifier.AddMembershipFunction( wrapperMf );
                        }
                    }
                }
                reader.Close();
            }
            catch ( Exception e )
            {
                LogWriter.Write( e.ToString() );
            }
        }
        */
        public static void SaveMemberFunctions( Fuzzifier fuzzifier, string file )
        {
            try
            {
                StreamWriter writer = new StreamWriter( file, false );

                IDictionaryEnumerator htEnumerator = fuzzifier.m_MembershipFunctions.GetEnumerator();
                while ( htEnumerator.MoveNext() )
                {
                    ArrayList currentFunctions = ( ArrayList )htEnumerator.Value;
                    for ( int i = 0; i < currentFunctions.Count; i++ )
                    {
                        string locked = "";
                        MfInterface memberFuncToSave = ( MfInterface )currentFunctions[i];

                        if ( memberFuncToSave.IsLocked() )
                            locked = " *";

                        if ( memberFuncToSave.SaveAble() )
                            writer.WriteLine( memberFuncToSave.VariableName() + " " + memberFuncToSave.TermName() + " " + memberFuncToSave.BaseLeft() + " " + memberFuncToSave.CenterMax() + " " + memberFuncToSave.BaseRight() + locked );
                    }
                }
                writer.Close();
            }
            catch ( Exception )
            {}
        }
コード例 #7
0
ファイル: Fuzzifier.cs プロジェクト: prezz/Fuzzy-Gammon
        public static void MakeReady( Fuzzifier fuzzifier )
        {
            fuzzifier.m_MembershipFunctions.Clear();

            string line;
            char[] separator = {' ', '\t', '\n'};
            string[] tokens;
            string[] s = MemberFunctionGrapper.GetFunctions();
            for ( int i = 0; i < s.Length; i++ )
            {
                line = s[i].Trim();
                if ( line.Length > 0 && line[0] != ';' )
                {
                    tokens = line.Split( separator );
                    MfInterface memberFunc = new MembershipFunction( tokens[0], tokens[1], double.Parse( tokens[2] ), double.Parse( tokens[3]), double.Parse( tokens[4] ) );

                    if ( tokens.Length > 5 && tokens[5].Equals("*") )
                        memberFunc.Lock( true );

                    fuzzifier.AddMembershipFunction( memberFunc );
                }
            }
        }
コード例 #8
0
ファイル: Fuzzifier.cs プロジェクト: prezz/Fuzzy-Gammon
        public static void LoadMemberFunctions( Fuzzifier fuzzifier, string file )
        {
            try
            {
                if ( File.Exists( file ) )
                {
                    fuzzifier.m_MembershipFunctions.Clear();

                    StreamReader reader = new StreamReader( file );
                    string line;
                    char[] separator = {' ', '\t', '\n'};
                    string[] tokens;
                    while ( ( line = reader.ReadLine() ) != null )
                    {
                        line = line.Trim();
                        if ( line.Length > 0 && line[0] != ';' )
                        {
                            tokens = line.Split( separator );
                            MfInterface memberFunc = new MembershipFunction( tokens[0], tokens[1], double.Parse( tokens[2] ), double.Parse( tokens[3]), double.Parse( tokens[4] ) );

                            if ( tokens.Length > 5 && tokens[5].Equals("*") )
                                memberFunc.Lock( true );

                            fuzzifier.AddMembershipFunction( memberFunc );
                        }
                    }
                    reader.Close();
                }
            }
            catch ( Exception e )
            {
                LogWriter.Write( e.ToString() );
            }
        }
コード例 #9
0
 public void Save()
 {
     Fuzzifier.SaveMemberFunctions(m_Fuzzifier, ".\\Fuzzeval.mf");
 }