Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/01/11 17:48:53 (13 years ago)
Author:
mkommend
Message:

#1479: Integrated trunk changes.

Location:
branches/GP.Grammar.Editor/HeuristicLab.Encodings.PermutationEncoding/3.3
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/GP.Grammar.Editor/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/UniformLikeCrossover.cs

    r6377 r6618  
    2929  [Item("UniformLikeCrossover", "The ULX crossover tries to maintain the position in the permutation. It randomly chooses from left to right one of its parents' alleles at each position. Missing entries are then filled randomly later. It is described in Tate, D. M. and Smith, A. E. 1995. A genetic approach to the quadratic assignment problem. Computers & Operations Research, vol. 22, pp. 73-83.")]
    3030  [StorableClass]
    31   public class UniformLikeCrossover : PermutationCrossover {
     31  public sealed class UniformLikeCrossover : PermutationCrossover {
    3232    [StorableConstructor]
    33     protected UniformLikeCrossover(bool deserializing) : base(deserializing) { }
    34     protected UniformLikeCrossover(UniformLikeCrossover original, Cloner cloner) : base(original, cloner) { }
     33    private UniformLikeCrossover(bool deserializing) : base(deserializing) { }
     34    private UniformLikeCrossover(UniformLikeCrossover original, Cloner cloner) : base(original, cloner) { }
    3535    public UniformLikeCrossover() : base() { }
    3636
  • branches/GP.Grammar.Editor/HeuristicLab.Encodings.PermutationEncoding/3.3/HeuristicLabEncodingsPermutationEncodingPlugin.cs.frame

    r6099 r6618  
    2626  /// Plugin class for HeuristicLab.Encodings.PermutationEncoding plugin.
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Encodings.PermutationEncoding", "3.3.4.$WCREV$")]
     28  [Plugin("HeuristicLab.Encodings.PermutationEncoding", "3.3.5.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Encodings.PermutationEncoding-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Collections", "3.3")]
  • branches/GP.Grammar.Editor/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEqualityComparer.cs

    r6377 r6618  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
     25using System.Text;
    2426using HeuristicLab.PluginInfrastructure;
    2527
    2628namespace HeuristicLab.Encodings.PermutationEncoding {
    2729  [NonDiscoverableType]
    28   public class PermutationEqualityComparer : IEqualityComparer<Permutation> {
    29     public bool Equals(Permutation x, Permutation y) {
     30  public class PermutationEqualityComparer : EqualityComparer<Permutation> {
     31    public override bool Equals(Permutation x, Permutation y) {
    3032      if (x.PermutationType != y.PermutationType) return false;
    3133      if (x.Length != y.Length) return false;
     
    4345
    4446    private bool EqualsAbsolute(Permutation x, Permutation y) {
    45       for (int i = 0; i < x.Length; i++)
    46         if (x[i] != y[i]) return false;
    47       return true;
     47      return x.SequenceEqual(y);
    4848    }
    4949
     
    6666    }
    6767
    68     public int GetHashCode(Permutation obj) {
     68    public override int GetHashCode(Permutation obj) {
    6969      if (obj == null) return 0;
    70       return obj.GetHashCode();
     70      return GenerateHashString(obj).GetHashCode();
     71    }
     72
     73    private string GenerateHashString(Permutation p) {
     74      StringBuilder sb = new StringBuilder();
     75      if (p.PermutationType == PermutationTypes.Absolute) {
     76        for (int i = 0; i < p.Length; i++)
     77          sb.Append(p[i].ToString() + ";");
     78      } else {
     79        int i = 0;
     80        while (p[i] != 0) i++; // always start at element 0
     81        if (p.PermutationType == PermutationTypes.RelativeDirected) {
     82          for (int j = 0; j < p.Length; j++)
     83            sb.Append(p.GetCircular(i + j).ToString() + ";");
     84        } else {
     85          bool goLeft = p.GetCircular(i - 1) < p.GetCircular(i + 1); // go in direction of the lowest edge so that the total inversion and its original return the same hash code
     86          for (int j = 0; j < p.Length; j++) {
     87            if (goLeft) sb.Append(p.GetCircular(i - j).ToString() + ";");
     88            else sb.Append(p.GetCircular(i + j).ToString() + ";");
     89          }
     90        }
     91      }
     92      return sb.ToString();
    7193    }
    7294  }
  • branches/GP.Grammar.Editor/HeuristicLab.Encodings.PermutationEncoding/3.3/Properties/AssemblyInfo.frame

    r6099 r6618  
    5454// by using the '*' as shown below:
    5555[assembly: AssemblyVersion("3.3.0.0")]
    56 [assembly: AssemblyFileVersion("3.3.4.$WCREV$")]
     56[assembly: AssemblyFileVersion("3.3.5.$WCREV$")]
  • branches/GP.Grammar.Editor/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/HeuristicLab.Encodings.PermutationEncoding-3.3.Tests.csproj

    r6377 r6618  
    112112    <Compile Include="OrderCrossoverTest.cs" />
    113113    <Compile Include="PartiallyMatchedCrossoverTest.cs" />
     114    <Compile Include="PermutationEqualityComparerTest.cs" />
    114115    <Compile Include="PositionBasedCrossoverTest.cs" />
    115116    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/GP.Grammar.Editor/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/Properties/AssemblyInfo.cs

    r5446 r6618  
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.3.0.0")]
    55 [assembly: AssemblyFileVersion("3.3.3.0")]
     55[assembly: AssemblyFileVersion("3.3.5.0")]
Note: See TracChangeset for help on using the changeset viewer.