private static void CreateMatrices(List <int> existingRelationshipDegrees, int quantityOfMatrixes, int generatedMatrixSize, double noRelationPercent, int minPercentOfMeaningfulValues, int maxPercentOfMeaningfulValues) { Parallel.For(0, quantityOfMatrixes, matrixNumber => { Console.WriteLine("Начинается построение матрицы #{0}...", matrixNumber); float[][] generatedOutputMatrix = GetOutputMatrix(generatedMatrixSize, existingRelationshipDegrees, noRelationPercent, matrixNumber, minPercentOfMeaningfulValues, maxPercentOfMeaningfulValues); float[][] generatedInputMatrix = GetInputMatrix(generatedOutputMatrix, generatedMatrixSize); Console.WriteLine("Завершено построение матрицы #{0}!", matrixNumber); /* * Сохранение входной матрицы в файл. */ Directory.CreateDirectory("input"); FileSaverLoader.SaveToFile(@"input/generated_input", generatedInputMatrix, matrixNumber); /* * Сохранение выходной матрицы в файл. */ Directory.CreateDirectory("output"); FileSaverLoader.SaveToFile(@"output/generated_output", generatedOutputMatrix, matrixNumber); }); }
public static void GetStaticData() { CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); Console.WriteLine("Подготовка необходимых файлов..."); RelationshipsMatrix = FileSaverLoader.LoadFromFile2dJagged("relationships.csv"); NumberOfProband = 0; int[][] _ancestorsMaxCountMatrix = FileSaverLoader.LoadFromFile2dInt("ancestorsMatrix.csv"); DescendantsList = FileSaverLoader.LoadFromFile1dInt("descendantsMatrix.csv").ToList(); List <RelationshipDegree> relationships = JsonConvert.DeserializeObject <List <RelationshipDegree> >(File.ReadAllText("relationships.json")); Console.WriteLine("Необходимые файлы успешно подготовлены!"); AncestorList = Enumerable .Range(0, _ancestorsMaxCountMatrix.GetLength(0)) .Select(x => _ancestorsMaxCountMatrix[x][0]) .ToList(); ExistingRelationshipDegrees = GetAllExistingRelationshipDegrees(); ExistingRelationshipDegrees.Insert(0, 0); RelationshipDegreesDictionary = new Dictionary <int, RelationshipDegree>(); foreach (RelationshipDegree relationship in relationships) { RelationshipDegreesDictionary.Add(relationship.RelationshipDegreeNumber, relationship); } }