当前位置: 首页>>代码示例>>C#>>正文


C# Problem.Execute方法代码示例

本文整理汇总了C#中Problem.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Problem.Execute方法的具体用法?C# Problem.Execute怎么用?C# Problem.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Problem的用法示例。


在下文中一共展示了Problem.Execute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            int countInput,countOutput,iterationsCount;
            List<int> layers = new List<int>();
            FunctionTypeEnum functionType;
            ProblemTypeEnum problemType;
            bool bias;
            double learningCoefficient, inertiaCoefficient;
            string trainFile, testFile;

            #region Handle configuration

            var countInputString = ConfigurationManager.AppSettings["CountInput"];
            if (!int.TryParse(countInputString, out countInput) || countInput<=0) { HandleError("CountInput"); return; }

            var countOutputString = ConfigurationManager.AppSettings["CountOutput"];
            if (!int.TryParse(countOutputString, out countOutput) || countOutput<=0) { HandleError("CountOutput"); return; }

            var iterationsCountString = ConfigurationManager.AppSettings["IterationsCount"];
            if (!int.TryParse(iterationsCountString, out iterationsCount) || iterationsCount <= 0) { HandleError("IterationsCount"); return; }

            var layerString = ConfigurationManager.AppSettings["Layers"];
            var layerStrings = layerString.Split(',');
            foreach(var layerStr in layerStrings)
            {
                int layerValue;
                if (!int.TryParse(layerStr, out layerValue) || layerValue <= 0) { HandleError("Layers"); return; }
                else { layers.Add(layerValue); }
            }

            var functionTypeString = ConfigurationManager.AppSettings["FunctionType"];
            if (functionTypeString == "Bipolar") functionType = FunctionTypeEnum.Bipolar;
            else if (functionTypeString == "Unipolar") functionType = FunctionTypeEnum.Unipolar;
            else { HandleError("FunctionType"); return; }

            var problemTypeString = ConfigurationManager.AppSettings["ProblemType"];
            if (problemTypeString == "Classification") problemType = ProblemTypeEnum.Classification;
            else if (problemTypeString == "Regression") problemType = ProblemTypeEnum.Regression;
            else { HandleError("ProblemType"); return; }

            var biasString = ConfigurationManager.AppSettings["Bias"];
            if (biasString == "true") bias = true;
            else if (biasString == "false") bias = false;
            else { HandleError("Bias"); return; }

            var learningCoefficientString = ConfigurationManager.AppSettings["LearningCoefficient"];
            if (!double.TryParse(learningCoefficientString,NumberStyles.AllowDecimalPoint,new CultureInfo("en-US"), out learningCoefficient) || learningCoefficient < 0 || learningCoefficient > 1) { HandleError("LearningCoefficient"); return; }

            var inertiaCoefficientString = ConfigurationManager.AppSettings["InertiaCoefficient"];
            if (!double.TryParse(inertiaCoefficientString, NumberStyles.AllowDecimalPoint, new CultureInfo("en-US"), out inertiaCoefficient) || inertiaCoefficient < 0 || inertiaCoefficient > 1) { HandleError("InertiaCoefficient"); return; }

            trainFile = ConfigurationManager.AppSettings["TrainingFile"];
            if (string.IsNullOrEmpty(trainFile)) { HandleError("TrainingFile"); return; }

            testFile = ConfigurationManager.AppSettings["TestingFile"];
            if (string.IsNullOrEmpty(testFile)) { HandleError("TestingFile"); return; }
            #endregion

            var parameters = new Parameters
            {
                Layers = layers,
                CountInput =countInput,
                CountOutput = countOutput,
                FunctionType = functionType,
                Bias = bias,
                IterationsCount = iterationsCount,
                LearingCoefficient = learningCoefficient,
                InertiaCoefficient = inertiaCoefficient,
                ProblemType = problemType,
                TrainFile=trainFile,
                TestFile=testFile
            };

            var problem = new Problem(parameters);
            problem.Execute();
        }
开发者ID:naporalukasz,项目名称:Sieci_Projekt1,代码行数:76,代码来源:Program.cs


注:本文中的Problem.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。