本文整理汇总了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);
}
示例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();
}