Changeset 5648 for branches/QAP/HeuristicLab.Problems.QuadraticAssignment
- Timestamp:
- 03/10/11 01:49:10 (14 years ago)
- Location:
- branches/QAP
- Files:
-
- 5 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/QAP
- Property svn:ignore
-
old new 1 1 *.suo 2 TestResults
-
- Property svn:ignore
-
branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Parsers/QAPLIBParser.cs
r5563 r5648 41 41 Distances = new double[Size, Size]; 42 42 Weights = new double[Size, Size]; 43 reader.ReadLine();43 string valLine = reader.ReadLine(); 44 44 char[] delim = new char[] { ' ' }; 45 45 for (int i = 0; i < Size; i++) { 46 string valLine = reader.ReadLine(); 46 if (i > 0 || String.IsNullOrWhiteSpace(valLine)) 47 valLine = reader.ReadLine(); 47 48 string[] vals = new string[Size]; 48 49 string[] partVals = valLine.Split(delim, StringSplitOptions.RemoveEmptyEntries); … … 59 60 } 60 61 } 61 reader.ReadLine();62 valLine = reader.ReadLine(); 62 63 int read = 0; 63 64 int k = 0; 64 65 while (!reader.EndOfStream) { 65 string valLine = reader.ReadLine(); 66 if (read > 0 || String.IsNullOrWhiteSpace(valLine)) 67 valLine = reader.ReadLine(); 66 68 string[] vals = valLine.Split(delim, StringSplitOptions.RemoveEmptyEntries); 67 69 for (int j = 0; j < vals.Length; j++) { -
branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Parsers/QAPLIBSolutionParser.cs
r5598 r5648 38 38 try { 39 39 StreamReader reader = new StreamReader(stream); 40 char[] delim = new char[] { ' ' };40 char[] delim = new char[] { ' ', ',' }; // comma is added for nug30.sln which is the only file that separates the permutation with commas 41 41 string[] firstline = reader.ReadLine().Split(delim, StringSplitOptions.RemoveEmptyEntries); 42 42 Size = int.Parse(firstline[0]); -
branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPAssignment.cs
r5641 r5648 18 18 coordinates = value; 19 19 if (changed) OnPropertyChanged("Coordinates"); 20 }21 }22 23 [Storable]24 private DoubleMatrix viewCoordinates;25 public DoubleMatrix ViewCoordinates {26 get { return viewCoordinates; }27 set {28 bool changed = (viewCoordinates != value);29 viewCoordinates = value;30 if (changed) OnPropertyChanged("ViewCoordinates");31 20 } 32 21 } … … 85 74 assignment = cloner.Clone(original.assignment); 86 75 quality = cloner.Clone(original.quality); 87 viewCoordinates = cloner.Clone(original.viewCoordinates);88 76 } 89 77 public QAPAssignment(DoubleMatrix weights, Permutation assignment) { -
branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
r5641 r5648 103 103 public QuadraticAssignmentProblem() 104 104 : base() { 105 Parameters.Add(new ValueParameter<Permutation>("BestKnownSolution", "The best known solution which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null));105 Parameters.Add(new OptionalValueParameter<Permutation>("BestKnownSolution", "The best known solution which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null)); 106 106 Parameters.Add(new ValueParameter<DoubleMatrix>("Coordinates", "The coordinates of the locations. If this is changed the distance matrix is calculated automatically using the euclidean distance.")); 107 107 Parameters.Add(new ValueParameter<DoubleMatrix>("Weights", "The strength of the connection between the facilities.", new DoubleMatrix(5, 5))); … … 272 272 private void UpdateDistanceMatrix() { 273 273 if (Coordinates != null && Coordinates.Columns == 2 && Coordinates.Rows > 1) { 274 D istanceMatrix= new DoubleMatrix(Coordinates.Rows, Coordinates.Rows);274 DoubleMatrix distance = new DoubleMatrix(Coordinates.Rows, Coordinates.Rows); 275 275 for (int i = 0; i < Coordinates.Rows - 1; i++) { 276 276 for (int j = i + 1; j < Coordinates.Rows; j++) { 277 277 double dx = Coordinates[i, 0] - Coordinates[j, 0]; 278 278 double dy = Coordinates[i, 1] - Coordinates[j, 1]; 279 DistanceMatrix[i, j] = Math.Sqrt(dx * dx + dy * dy);280 DistanceMatrix[j, i] = DistanceMatrix[i, j];279 distance[i, j] = Math.Sqrt(dx * dx + dy * dy); 280 distance[j, i] = DistanceMatrix[i, j]; 281 281 } 282 282 } 283 DistanceMatrix = distance; 283 284 } 284 285 }
Note: See TracChangeset
for help on using the changeset viewer.