Changeset 8221
- Timestamp:
- 07/04/12 23:54:15 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPDistanceMatrixEvaluator.cs
r7558 r8221 59 59 if (distances == null || distances.Rows == 0 || distances.Columns == 0 60 60 || distances.Rows != distances.Columns) 61 throw new InvalidOperationException("T he distance matrix is empty or not square");62 if (tour == null) throw new ArgumentNullException("tour", " No tour is given.");61 throw new InvalidOperationException("TSPDistanceMatrixEvaluator: The distance matrix is empty or not square"); 62 if (tour == null) throw new ArgumentNullException("tour", "TSPDistanceMatrixEvaluator: No tour is given."); 63 63 Permutation p = tour; 64 64 double length = 0; -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
r8208 r8221 112 112 Parameters.Add(new OptionalValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the cities.")); 113 113 Parameters.Add(new OptionalValueParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities.")); 114 Parameters.Add(new ValueParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false.", new BoolValue(true)));114 Parameters.Add(new ValueParameter<BoolValue>("UseDistanceMatrix", "True if the coordinates based evaluators should calculate the distance matrix from the coordinates and use it for evaluation similar to the distance matrix evaluator, otherwise false.", new BoolValue(true))); 115 115 Parameters.Add(new OptionalValueParameter<Permutation>("BestKnownSolution", "The best known solution of this TSP instance.")); 116 116 117 117 Maximization.Value = false; 118 118 MaximizationParameter.Hidden = true; 119 UseDistanceMatrixParameter.Hidden = true; 119 120 DistanceMatrixParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false; 120 121 … … 151 152 UpdateMoveEvaluators(); 152 153 ParameterizeAnalyzers(); 153 ClearDistanceMatrix(); 154 if (Evaluator is ITSPCoordinatesPathEvaluator && Coordinates != null) 155 ClearDistanceMatrix(); 154 156 } 155 157 private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) { … … 158 160 Coordinates.Reset += new EventHandler(Coordinates_Reset); 159 161 } 160 ParameterizeSolutionCreator(); 161 ClearDistanceMatrix(); 162 if (Evaluator is ITSPCoordinatesPathEvaluator) { 163 ParameterizeSolutionCreator(); 164 ClearDistanceMatrix(); 165 } 162 166 } 163 167 private void Coordinates_ItemChanged(object sender, EventArgs<int, int> e) { 164 ClearDistanceMatrix(); 168 if (Evaluator is ITSPCoordinatesPathEvaluator) { 169 ClearDistanceMatrix(); 170 } 165 171 } 166 172 private void Coordinates_Reset(object sender, EventArgs e) { 167 ParameterizeSolutionCreator(); 168 ClearDistanceMatrix(); 173 if (Evaluator is ITSPCoordinatesPathEvaluator) { 174 ParameterizeSolutionCreator(); 175 ClearDistanceMatrix(); 176 } 169 177 } 170 178 private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) { … … 346 354 347 355 private void ClearDistanceMatrix() { 348 if (!(Evaluator is ITSPDistanceMatrixEvaluator)) 349 DistanceMatrixParameter.Value = null; 356 DistanceMatrixParameter.Value = null; 350 357 } 351 358 #endregion … … 365 372 Description = data.Description; 366 373 374 bool clearCoordinates = false, clearDistanceMatrix = false; 367 375 if (data.Coordinates != null && data.Coordinates.GetLength(0) > 0) 368 376 Coordinates = new DoubleMatrix(data.Coordinates); 369 else Coordinates = null;377 else clearCoordinates = true; 370 378 371 379 TSPEvaluator evaluator; … … 382 390 DistanceMatrix = new DistanceMatrix(data.Distances); 383 391 } else { 384 DistanceMatrix = null;392 clearDistanceMatrix = true; 385 393 UseDistanceMatrix = new BoolValue(data.Dimension <= DistanceMatrixSizeLimit); 386 394 switch (data.DistanceMeasure) { … … 401 409 Evaluator = evaluator; 402 410 411 // reset them after assigning the evaluator 412 if (clearCoordinates) Coordinates = null; 413 if (clearDistanceMatrix) DistanceMatrix = null; 414 403 415 BestKnownSolution = null; 404 416 BestKnownQuality = null;
Note: See TracChangeset
for help on using the changeset viewer.