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


C# IAlgorithm.Run方法代码示例

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


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

示例1: Test_result

        public Test_result(IMatrixReadStorage<int, EmptyData> storage, IMatrixReadStorage<int, SolutionData> datastorage, IAlgorithm<int> algorithm, PartitioningParameters parameters)
        {
            results = new AllResults();
            InitializeComponent();
            foreach (var matrixData in storage.ReadMatrixes())
            {
                string name = matrixData.Name;
                IMatrix<int> matrix = matrixData.Matrix;
                int n = matrixData.Matrix.Size(0);
                int m = matrixData.Matrix.Size(1);
                int M1 = parameters[0];
                int M2 = parameters[1];
                Int64 start = Stopwatch.GetTimestamp();
                ISolution solution = algorithm.Run(matrix);
                double time = (Stopwatch.GetTimestamp() - start) / (double)Stopwatch.Frequency;
                double crit = MinMaxCriterium.Calculate(matrix, solution);
                double w = Utilities.W(matrix, parameters);
                double diff = crit - w;
                results.AddElem(new Note(name, n, m, M1, M2, crit, diff, 0, time, false));

            }
            foreach (var matrixData in datastorage.ReadMatrixes())
            {
                string name = matrixData.Name;
                IMatrix<int> matrix = matrixData.Matrix;
                int n = matrixData.Matrix.Size(0);
                int m = matrixData.Matrix.Size(1);
                PartitioningParameters dataParameters = matrixData.Data.Item1;
                int M1 = dataParameters[0];
                int M2 = dataParameters[1];
                double goodCrit = matrixData.Data.Item3;
                Int64 start = Stopwatch.GetTimestamp();
                ISolution solution = algorithm.Run(matrix);
                double time = (Stopwatch.GetTimestamp() - start) / (double)Stopwatch.Frequency;
                double crit = CoreUtilities.Utilities.Max(new SplittedMatrix(matrix, solution));
                double w = Utilities.W(matrix, dataParameters);
                double diff = crit - w;
                double goodDiff = crit - goodCrit;
                results.AddElem(new Note(name, n, m, M1, M2, crit, diff, goodDiff, time, true));

            }
            results.GetGroups(GroupedResults);
        }
开发者ID:sergey-and-valya,项目名称:load-balancing,代码行数:43,代码来源:Test+result.cs

示例2: Run

        public void Run(IAlgorithm algorithm, IDictionary<string, string> parameters)
        {
            status = RunnerStatus.Running;
            algorithm.AlgorithmRunner = this;

            new Thread(() =>
                {
                    try
                    {
                        Console.WriteLine("Worker thread running algorithm...");
                        var result = algorithm.Run(parameters);
                        workerPool.FinishComputation(Id, true, result);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error in thread running algorithm: " + ex.Message);
                        workerPool.FinishComputation(Id, false);
                    }
                    finally
                    {
                        status = RunnerStatus.Idle;
                    }
                }).Start();
        }
开发者ID:AnObfuscator,项目名称:Dispartior,代码行数:24,代码来源:Worker.cs


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