Changeset 15490 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common/3.3
- Timestamp:
- 12/04/17 23:00:03 (6 years ago)
- Location:
- branches/GeneralizedQAP
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP
- Property svn:ignore
-
old new 2 2 TestResults 3 3 *.user 4 .vs
-
- Property svn:ignore
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common/3.3
- Property svn:ignore
-
old new 1 1 obj 2 2 Plugin.cs 3 *.user
-
- Property svn:ignore
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common-3.3.csproj
r13418 r15490 69 69 <Private>False</Private> 70 70 </Reference> 71 <Reference Include="HeuristicLab.Optimization-3.3">72 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>73 <Private>False</Private>74 </Reference>75 71 <Reference Include="HeuristicLab.Parameters-3.3"> 76 72 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath> … … 102 98 <None Include="HeuristicLab.snk" /> 103 99 </ItemGroup> 100 <ItemGroup> 101 <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj"> 102 <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project> 103 <Name>HeuristicLab.Optimization-3.3</Name> 104 <Private>False</Private> 105 </ProjectReference> 106 </ItemGroup> 104 107 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 105 108 <PropertyGroup> -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common/3.3/IntegerVectorEqualityComparer.cs
r7432 r15490 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 using HeuristicLab.Encodings.IntegerVectorEncoding;24 24 25 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common { 26 public class IntegerVectorEqualityComparer : EqualityComparer<IntegerVector> { 27 public override bool Equals(IntegerVector x, IntegerVector y) { 28 if (x == null || y == null) return false; 29 if (x.Length != y.Length) return false; 30 31 for (int i = 0; i < x.Length; i++) 32 if (x[i] != y[i]) return false; 33 34 return true; 35 } 36 37 public override int GetHashCode(IntegerVector obj) { 38 return obj.GetHashCode(); 39 } 40 41 public static double GetSimilarity(IntegerVector a, IntegerVector b) { 42 int similar = 0; 43 for (int i = 0; i < a.Length; i++) { 44 if (a[i] == b[i]) similar++; 45 } 46 return similar / (double)a.Length; 47 } 48 49 public static double GetDistance(IntegerVector a, IntegerVector b) { 50 return 1.0 - GetSimilarity(a, b); 51 } 52 53 public static IEnumerable<int> GetDifferingIndices(IntegerVector a, IntegerVector b) { 25 namespace HeuristicLab.Encodings.IntegerVectorEncoding { 26 public static class IntegerVectorExtensions { 27 public static IEnumerable<int> GetDifferingIndices(this IntegerVector a, IntegerVector b) { 28 if (b == null) throw new ArgumentNullException("b"); 54 29 for (int i = 0; i < a.Length; i++) 55 30 if (a[i] != b[i]) yield return i;
Note: See TracChangeset
for help on using the changeset viewer.