/// <summary> /// Generate the permutations according to some algorithm /// </summary> /// <param name = "algorithm">Algorithm of generation of the permutations</param> /// <returns>String to be save into the file</returns> private string Generate(PermutationAlgorithm algorithm) { const string begin = "INSERT INTO Permutations VALUES ("; @from = (int)_nudFrom.Value; to = (int)_nudTo.Value; hashTables = (int)_nudLTables.Value; keysPerTale = (int)_nudKeys.Value; StringBuilder final = new StringBuilder(); Dictionary <int, int[]> perms = null; IMinMutualSelector selector = null; switch (algorithm) { case PermutationAlgorithm.UniqueIndexesAcrossPermutation: /*Unique random permutations*/ perms = permutationGeneratorService.GenerateRandomPermutationsUsingUniqueIndexes(hashTables, keysPerTale, @from, to); break; case PermutationAlgorithm.AgressiveSelector: /*Aggressive selector*/ selector = new AgressiveSelector(); perms = permutationGeneratorService.GeneratePermutationsUsingMinMutualInformation(hashTables, keysPerTale, @from, to, selector); break; case PermutationAlgorithm.SummedAccrossSelector: /*SummedAccross selector*/ selector = new SummedAcrossSelector(); perms = permutationGeneratorService.GeneratePermutationsUsingMinMutualInformation(hashTables, keysPerTale, @from, to, selector); break; case PermutationAlgorithm.ConservativeSelector: /*Conservative selector*/ selector = new ConservativeSelector(); perms = permutationGeneratorService.GeneratePermutationsUsingMinMutualInformation(hashTables, keysPerTale, @from, to, selector); break; } /*Create *.txt string*/ if (perms != null) { foreach (KeyValuePair <int, int[]> perm in perms) { final.Append(begin); StringBuilder permutation = new StringBuilder(); permutation.Append(perm.Key + ",'"); foreach (int t in perm.Value) { permutation.Append(t + ";"); } permutation.Append("');"); final.AppendLine(permutation.ToString()); } } return(final.ToString()); }
/// <summary> /// Generate the permutations according to some algorithm /// </summary> /// <param name = "algorithm">Algorithm of generation of the permutations</param> /// <returns>String to be save into the file</returns> private string Generate(PermutationAlgorithm algorithm) { const string begin = "INSERT INTO Permutations VALUES ("; @from = (int) _nudFrom.Value; to = (int) _nudTo.Value; hashTables = (int) _nudLTables.Value; keysPerTale = (int) _nudKeys.Value; StringBuilder final = new StringBuilder(); Dictionary<int, int[]> perms = null; IMinMutualSelector selector = null; switch (algorithm) { case PermutationAlgorithm.UniqueIndexesAcrossPermutation: /*Unique random permutations*/ perms = permutationGeneratorService.GenerateRandomPermutationsUsingUniqueIndexes(hashTables, keysPerTale, @from, to); break; case PermutationAlgorithm.AgressiveSelector: /*Aggressive selector*/ selector = new AgressiveSelector(); perms = permutationGeneratorService.GeneratePermutationsUsingMinMutualInformation(hashTables, keysPerTale, @from, to, selector); break; case PermutationAlgorithm.SummedAccrossSelector: /*SummedAccross selector*/ selector = new SummedAcrossSelector(); perms = permutationGeneratorService.GeneratePermutationsUsingMinMutualInformation(hashTables, keysPerTale, @from, to, selector); break; case PermutationAlgorithm.ConservativeSelector: /*Conservative selector*/ selector = new ConservativeSelector(); perms = permutationGeneratorService.GeneratePermutationsUsingMinMutualInformation(hashTables, keysPerTale, @from, to, selector); break; } /*Create *.txt string*/ if (perms != null) foreach (KeyValuePair<int, int[]> perm in perms) { final.Append(begin); StringBuilder permutation = new StringBuilder(); permutation.Append(perm.Key + ",'"); foreach (int t in perm.Value) permutation.Append(t + ";"); permutation.Append("');"); final.AppendLine(permutation.ToString()); } return final.ToString(); }