Changeset 6647 for branches/GP.Grammar.Editor/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPAlleleFrequencyAnalyzer.cs
- Timestamp:
- 08/09/11 11:01:08 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP.Grammar.Editor/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPAlleleFrequencyAnalyzer.cs
r6377 r6647 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using HeuristicLab.Analysis; 23 24 using HeuristicLab.Common; … … 56 57 57 58 protected override Allele[] CalculateAlleles(Permutation solution) { 58 Allele[] alleles = new Allele[solution.Length]; 59 Allele[] alleles = new Allele[solution.Length * solution.Length]; 60 Dictionary<string, int> allelesDict = new Dictionary<string, int>(); 59 61 DoubleMatrix weights = WeightsParameter.ActualValue; 60 62 DoubleMatrix distances = DistancesParameter.ActualValue; 61 int source, target;62 63 double impact; 63 64 64 for (int i = 0; i < solution.Length; i++) { 65 source = i; 66 target = solution[i]; 67 impact = 0; 68 for (int j = 0; j < solution.Length; j++) 69 impact += weights[source, j] * distances[target, solution[j]]; 70 alleles[i] = new Allele(source.ToString() + "->" + target.ToString(), impact); 65 for (int x = 0; x < solution.Length; x++) { 66 for (int y = 0; y < solution.Length; y++) { 67 string allele = weights[x, y].ToString() + ">" + distances[solution[x], solution[y]].ToString(); 68 int repetition = 1; 69 if (allelesDict.ContainsKey(allele)) repetition += allelesDict[allele]; 70 allelesDict[allele] = repetition; 71 impact = weights[x, y] * distances[solution[x], solution[y]]; 72 alleles[x * solution.Length + y] = new Allele(allele + "/" + repetition, impact); 73 } 71 74 } 72 75
Note: See TracChangeset
for help on using the changeset viewer.