Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/09/11 11:01:08 (13 years ago)
Author:
mkommend
Message:

#1479: Updated grammar editor branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GP.Grammar.Editor/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPAlleleFrequencyAnalyzer.cs

    r6377 r6647  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using HeuristicLab.Analysis;
    2324using HeuristicLab.Common;
     
    5657
    5758    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>();
    5961      DoubleMatrix weights = WeightsParameter.ActualValue;
    6062      DoubleMatrix distances = DistancesParameter.ActualValue;
    61       int source, target;
    6263      double impact;
    6364
    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        }
    7174      }
    7275
Note: See TracChangeset for help on using the changeset viewer.