Changeset 4825 for trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
- Timestamp:
- 11/17/10 07:41:28 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
r4722 r4825 55 55 get { return (ValueParameter<DoubleMatrix>)Parameters["Coordinates"]; } 56 56 } 57 public OptionalValueParameter<D oubleMatrix> DistanceMatrixParameter {58 get { return (OptionalValueParameter<D oubleMatrix>)Parameters["DistanceMatrix"]; }57 public OptionalValueParameter<DistanceMatrix> DistanceMatrixParameter { 58 get { return (OptionalValueParameter<DistanceMatrix>)Parameters["DistanceMatrix"]; } 59 59 } 60 60 public ValueParameter<BoolValue> UseDistanceMatrixParameter { … … 89 89 set { CoordinatesParameter.Value = value; } 90 90 } 91 public D oubleMatrix DistanceMatrix {91 public DistanceMatrix DistanceMatrix { 92 92 get { return DistanceMatrixParameter.Value; } 93 93 set { DistanceMatrixParameter.Value = value; } … … 144 144 : base(original, cloner) { 145 145 this.operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList(); 146 this.DistanceMatrixParameter.Value = original.DistanceMatrixParameter.Value;147 146 AttachEventHandlers(); 148 147 } … … 157 156 Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as the Traveling Salesman Problem is a minimization problem.", new BoolValue(false))); 158 157 Parameters.Add(new ValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the cities.")); 159 Parameters.Add(new OptionalValueParameter<D oubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));158 Parameters.Add(new OptionalValueParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities.")); 160 159 Parameters.Add(new ValueParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false.", new BoolValue(true))); 161 160 Parameters.Add(new ValueParameter<IPermutationCreator>("SolutionCreator", "The operator which should be used to create new TSP solutions.", creator)); … … 163 162 Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this TSP instance.")); 164 163 Parameters.Add(new OptionalValueParameter<Permutation>("BestKnownSolution", "The best known solution of this TSP instance.")); 164 165 DistanceMatrixParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false; 165 166 166 167 Coordinates = new DoubleMatrix(new double[,] { … … 258 259 // BackwardsCompatibility3.3 259 260 #region Backwards compatible code (remove with 3.4) 261 OptionalValueParameter<DoubleMatrix> oldDistanceMatrixParameter = Parameters["DistanceMatrix"] as OptionalValueParameter<DoubleMatrix>; 262 if (oldDistanceMatrixParameter != null) { 263 Parameters.Remove(oldDistanceMatrixParameter); 264 Parameters.Add(new OptionalValueParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities.")); 265 DistanceMatrixParameter.GetsCollected = oldDistanceMatrixParameter.GetsCollected; 266 DistanceMatrixParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false; 267 if (oldDistanceMatrixParameter.Value != null) { 268 DoubleMatrix oldDM = oldDistanceMatrixParameter.Value; 269 DistanceMatrix newDM = new DistanceMatrix(oldDM.Rows, oldDM.Columns, oldDM.ColumnNames, oldDM.RowNames); 270 newDM.SortableView = oldDM.SortableView; 271 for (int i = 0; i < newDM.Rows; i++) 272 for (int j = 0; j < newDM.Columns; j++) 273 newDM[i, j] = oldDM[i, j]; 274 DistanceMatrixParameter.Value = (DistanceMatrix)newDM.AsReadOnly(); 275 } 276 } 277 260 278 if (operators == null) InitializeOperators(); 261 279 #endregion
Note: See TracChangeset
for help on using the changeset viewer.