Free cookie consent management tool by TermsFeed Policy Generator

# Changeset 5931

Ignore:
Timestamp:
04/02/11 16:45:04 (13 years ago)
Message:
• changes according to the review
Location:
branches/QAP
Files:
9 edited

Unmodified
Removed
• ## branches/QAP/HeuristicLab.Analysis/3.3/HeuristicLabAnalysisPlugin.cs.frame

 r5446 [Plugin("HeuristicLab.Analysis", "3.3.3.$WCREV$")] [PluginFile("HeuristicLab.Analysis-3.3.dll", PluginFileType.Assembly)] [PluginDependency("HeuristicLab.ALGLIB", "3.1")] [PluginDependency("HeuristicLab.Collections", "3.3")] [PluginDependency("HeuristicLab.Common", "3.3")]
• ## branches/QAP/HeuristicLab.Analysis/3.3/MultidimensionalScaling/MultidimensionalScaling.cs

 r5871 /// Performs the Kruskal-Shepard algorithm and applies a gradient descent method /// to fit the coordinates such that the difference between the fit distances /// and the actual distances becomes minimal. /// and the dissimilarities becomes minimal. /// /// /// It will initialize the coordinates in a deterministic fashion such that all initial points are equally spaced on a circle. /// /// A symmetric NxN matrix that specifies the distances between each element i and j. Diagonal elements are ignored. /// A symmetric NxN matrix that specifies the dissimilarities between each element i and j. Diagonal elements are ignored. /// /// A Nx2 matrix where the first column represents the x- and the second column the y coordinates. int dimension = dissimilarities.Rows; if (dimension == 1) return new DoubleMatrix(new double[,] { { 0, 0 } }); else if (dimension == 2) return new DoubleMatrix(new double[,] { { 0, dissimilarities[0, 1] } }); else if (dimension == 2) return new DoubleMatrix(new double[,] { { 0, 0 }, { 0, dissimilarities[0, 1] } }); DoubleMatrix coordinates = new DoubleMatrix(dimension, 2); /// Performs the Kruskal-Shepard algorithm and applies a gradient descent method /// to fit the coordinates such that the difference between the fit distances /// and the actual distances is minimal. /// and the dissimilarities is minimal. /// /// /// It will use a pre-initialized x,y-coordinates matrix as a starting point of the gradient descent. /// /// A symmetric NxN matrix that specifies the distances between each element i and j. Diagonal elements are ignored. /// /// A symmetric NxN matrix that specifies the dissimilarities between each element i and j. Diagonal elements are ignored. /// The Nx2 matrix of initial coordinates. /// The number of iterations for which the algorithm should run. /// In every iteration it tries to find the best location for every item. /// A Nx2 matrix where the first column represents the x- and the second column the y coordinates. public static DoubleMatrix KruskalShepard(DoubleMatrix dissimilarities, DoubleMatrix coordinates) { public static DoubleMatrix KruskalShepard(DoubleMatrix dissimilarities, DoubleMatrix coordinates, int maximumIterations = 100) { int dimension = dissimilarities.Rows; if (dimension != dissimilarities.Columns || coordinates.Rows != dimension) throw new ArgumentException("The number of coordinates and the number of rows and columns in the dissimilarities matrix do not match."); alglib.mincgreport rep; for (int iterations = 0; iterations < 10; iterations++) { for (int iterations = 0; iterations < maximumIterations; iterations++) { bool changed = false; for (int i = 0; i < dimension; i++) { double[] c = new double[] { coordinates[i, 0], coordinates[i, 1] }; } catch (alglib.alglibexception) { } if (!double.IsNaN(c[0]) && !double.IsNaN(c[1])) { changed = changed || (coordinates[i, 0] != c[0]) || (coordinates[i, 1] != c[1]); coordinates[i, 0] = c[0]; coordinates[i, 1] = c[1]; } } if (!changed) break; } return coordinates; Info info = (obj as Info); for (int i = 0; i < info.Coordinates.Rows; i++) { double c = info.Distances[info.Row, i]; double c = info.Dissimilarities[info.Row, i]; if (i != info.Row) { double a = info.Coordinates[i, 0]; for (int i = 0; i < dimension - 1; i++) { for (int j = i + 1; j < dimension; j++) { if (dissimilarities[i, j] != dissimilarities[j, i]) throw new ArgumentException("Distances is not a symmetric matrix.", "distances"); if (dissimilarities[i, j] != dissimilarities[j, i]) throw new ArgumentException("Dissimilarities is not a symmetric matrix.", "dissimilarities"); if (dissimilarities[i, j] != 0) { stress += Stress(coordinates[i, 0], coordinates[i, 1], dissimilarities[i, j], coordinates[j, 0], coordinates[j, 1]); private class Info { public DoubleMatrix Coordinates { get; set; } public DoubleMatrix Distances { get; set; } public DoubleMatrix Dissimilarities { get; set; } public int Row { get; set; } public Info(DoubleMatrix c, DoubleMatrix d, int r) { Coordinates = c; Distances = d; Dissimilarities = d; Row = r; }
• ## branches/QAP/HeuristicLab.Analysis/3.3/Tests/HeuristicLab.Analysis.Tests-3.3.csproj

 r5873 prompt4 true bin\x86\Debug\ DEBUG;TRACE full x86 bin\Debug\HeuristicLab.Analysis.Tests.dll.CodeAnalysisLog.xml true GlobalSuppressions.cs prompt MinimumRecommendedRules.ruleset ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets true ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules true bin\x86\Release\ TRACE true pdbonly x86 bin\Release\HeuristicLab.Analysis.Tests.dll.CodeAnalysisLog.xml true GlobalSuppressions.cs prompt MinimumRecommendedRules.ruleset ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets false ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules false true bin\x64\Debug\ DEBUG;TRACE full x64 bin\Debug\HeuristicLab.Analysis.Tests.dll.CodeAnalysisLog.xml true GlobalSuppressions.cs prompt MinimumRecommendedRules.ruleset ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets true ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules true false bin\x64\Release\ TRACE true pdbonly x64 bin\Release\HeuristicLab.Analysis.Tests.dll.CodeAnalysisLog.xml true GlobalSuppressions.cs prompt MinimumRecommendedRules.ruleset ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets false ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules false
• ## branches/QAP/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/Swap2/ExhaustiveSwap2MoveGenerator.cs

 r5838 if (length == 1) throw new ArgumentException("ExhaustiveSwap2MoveGenerator: There cannot be an Swap move given a permutation of length 1.", "permutation"); int totalMoves = (length) * (length - 1) / 2; Swap2Move[] moves = null; Swap2Move[] moves = new Swap2Move[totalMoves]; int count = 0; if (permutation.PermutationType == PermutationTypes.RelativeUndirected) { if (totalMoves - 3 > 0) { moves = new Swap2Move[totalMoves - 3]; for (int i = 0; i < length - 1; i++) { for (int j = i + 1; j < length; j++) { if (j - i >= length - 2) continue; moves[count++] = new Swap2Move(i, j); } } } else { // when length is 3 or less, there's actually no difference, but for the sake of not crashing the algorithm create a dummy move moves = new Swap2Move[1]; moves[0] = new Swap2Move(0, 1); for (int i = 0; i < length - 1; i++) for (int j = i + 1; j < length; j++) { moves[count++] = new Swap2Move(i, j); } } else { moves = new Swap2Move[totalMoves]; for (int i = 0; i < length - 1; i++) for (int j = i + 1; j < length; j++) { moves[count++] = new Swap2Move(i, j); } } return moves; }
• ## branches/QAP/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/Swap2/StochasticSwap2SingleMoveGenerator.cs

 r5838 public static Swap2Move Apply(Permutation permutation, IRandom random) { int length = permutation.Length; if (length == 1) throw new ArgumentException("StochasticSwap2SingleMoveGenerator: There cannot be an Swap move given a permutation of length 1.", "permutation"); int index1 = random.Next(length - 1); int index2 = random.Next(index1 + 1, length); if (length < 2) throw new ArgumentException("StochasticSwap2SingleMoveGenerator: There cannot be a swap-2 move given a permutation of length less than 2.", "permutation"); int index1 = random.Next(length), index2 = 0; do { index2 = random.Next(length); } while (index1 == index2); return new Swap2Move(index1, index2); }