/* * 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) {} }
public int GetMembershipFunctionId(string linguisticVar, string linguisticTerm) { for (int i = 0; i < MemberFunctionsCount(); i++) { MfInterface mf = GetMembershipFunction(i); if (mf.VariableName().Equals(linguisticVar) && mf.TermName().Equals(linguisticTerm)) { return(i); } } return(-1); }
public MfInterface[] GetMembershipFunctions(string lingisticVar) { if (m_MembershipFunctions.ContainsKey(lingisticVar)) { ArrayList al = ( ArrayList )m_MembershipFunctions[lingisticVar]; MfInterface[] result = new MfInterface[al.Count]; for (int i = 0; i < al.Count; i++) { result[i] = ( MfInterface )al[i]; } return(result); } LogWriter.Write("Fuzzifier does not contain membership functions for " + lingisticVar); return(null); }
public void AddMembershipFunction(MfInterface memberFunc) { if (m_MembershipFunctions.ContainsKey(memberFunc.VariableName())) { ArrayList al = ( ArrayList )m_MembershipFunctions[memberFunc.VariableName()]; for (int i = 0; i < al.Count; i++) { if ((( MfInterface )al[i]).TermName().Equals(memberFunc.TermName())) { return; } } al.Add(memberFunc); m_MfKeys.Add(new MfKey(memberFunc.VariableName(), memberFunc.TermName())); } else { ArrayList al = new ArrayList(); al.Add(memberFunc); m_MembershipFunctions.Add(memberFunc.VariableName(), al); m_MfKeys.Add(new MfKey(memberFunc.VariableName(), memberFunc.TermName())); } }
public RedefinedMemberFunction(string variableName, MfInterface wrappedMf) { m_VariableName = variableName; m_WrappedMf = wrappedMf; }
public RedefinedMemberFunction( string variableName, MfInterface wrappedMf ) { m_VariableName = variableName; m_WrappedMf = wrappedMf; }
public MfInterface[] GetMembershipFunctions( string lingisticVar ) { if ( m_MembershipFunctions.ContainsKey( lingisticVar ) ) { ArrayList al = ( ArrayList )m_MembershipFunctions[lingisticVar]; MfInterface[] result = new MfInterface[al.Count]; for ( int i = 0; i < al.Count; i++ ) result[i] = ( MfInterface )al[i]; return result; } LogWriter.Write( "Fuzzifier does not contain membership functions for " + lingisticVar ); return null; }
public void AddMembershipFunction( MfInterface memberFunc ) { if ( m_MembershipFunctions.ContainsKey( memberFunc.VariableName() ) ) { ArrayList al = ( ArrayList )m_MembershipFunctions[memberFunc.VariableName()]; for ( int i = 0; i < al.Count; i++ ) if ( ( ( MfInterface )al[i] ).TermName().Equals( memberFunc.TermName() ) ) return; al.Add( memberFunc ); m_MfKeys.Add( new MfKey( memberFunc.VariableName(), memberFunc.TermName() ) ); } else { ArrayList al = new ArrayList(); al.Add( memberFunc ); m_MembershipFunctions.Add( memberFunc.VariableName(), al ); m_MfKeys.Add( new MfKey( memberFunc.VariableName(), memberFunc.TermName() ) ); } }