コード例 #1
0
ファイル: DataProvider.cs プロジェクト: osnihur/fuzzycheck
        public static void SaveInputVariables(ParamsList inputVariables)
        {
            // xml
            string dirName = "variables_t1_" + DateTime.Now.Ticks;
            Directory.CreateDirectory(dirName);
            XmlSerializer x = new XmlSerializer(typeof(ParamsList));
            TextWriter writer = new StreamWriter(string.Format("{0}\\variables.xml", dirName));
            x.Serialize(writer, inputVariables);

            // MF images
            Directory.CreateDirectory(string.Format("{0}\\variables", dirName));
            foreach (var parameter in inputVariables.Items)
            {
                parameter.TermsImg.Save(string.Format("{0}\\variables\\{1}.png", dirName, parameter.ParamName));
            }
        }
コード例 #2
0
        private static ParamsList VariablesToSerializableParameters(List<FuzzyVariable> variables)
        {
            ParamsList serializableParameters = new ParamsList();
            foreach (var fsInputVariable in variables)
            {
                ParameterXml param = new ParameterXml
                                  {
                                      ParamName = fsInputVariable.Name,
                                      Max = fsInputVariable.Max,
                                      Min = fsInputVariable.Min,
                                      Type = ParameterType.Input,
                                      Unit = fsInputVariable.Unit,
                                      Terms = new List<Term>()
                                  };

                foreach (var inputVariableTerm in fsInputVariable.Terms)
                {
                    var mf = inputVariableTerm.MembershipFunction as NormalMembershipFunction;
                    if (mf != null)
                    {
                        param.Terms.Add(new Term { Name = inputVariableTerm.Name, b = mf.B, c = mf.Sigma });
                    }
                }

                param.TermsImg = GetTermImg(fsInputVariable);
                serializableParameters.Items.Add(param);
            }

            return serializableParameters;
        }