Changeset 3209
- Timestamp:
- 03/24/10 21:15:04 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 12 added
- 5 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/HeuristicLab.Encodings.PermutationEncoding-3.3.csproj
r3200 r3209 108 108 <Compile Include="Manipulators\TranslocationManipulator.cs" /> 109 109 <Compile Include="Moves\ThreeIndexMove.cs" /> 110 <Compile Include="Moves\ThreeOpt\StochasticThreeOptMultiMoveGenerator.cs" /> 110 111 <Compile Include="Moves\ThreeOpt\ThreeOptMove.cs"> 111 112 <SubType>Code</SubType> 112 113 </Compile> 114 <Compile Include="Moves\ThreeOpt\ThreeOptMoveGenerator.cs" /> 115 <Compile Include="Moves\ThreeOpt\ThreeOptMoveMaker.cs" /> 113 116 <Compile Include="Moves\TwoOpt\PreventReaddTwoOptTabuMoveEvaluator.cs" /> 114 117 <Compile Include="Moves\TwoOpt\StochasticTwoOptSingleMoveGenerator.cs" /> -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r3187 r3209 252 252 private void InitializeOperators() { 253 253 operators = new List<IOperator>(); 254 if (ApplicationManager.Manager != null) { 255 foreach (IRealVectorOperator op in ApplicationManager.Manager.GetInstances<IRealVectorOperator>()) 256 operators.Add(op); 257 UpdateMoveEvaluators(); 258 ParameterizeOperators(); 259 } 254 if (ApplicationManager.Manager != null) operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>()); 255 UpdateMoveEvaluators(); 256 ParameterizeOperators(); 260 257 InitializeMoveGenerators(); 261 258 } -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/HeuristicLab.Problems.TravelingSalesman-3.3.csproj
r3200 r3209 87 87 <Compile Include="Evaluators\TSPGeoPathEvaluator.cs" /> 88 88 <Compile Include="HeuristicLabProblemsTravelingSalesmanPlugin.cs" /> 89 <Compile Include="MoveEvaluators\ThreeOptMoveTSPCoordinatesPathEvaluator.cs" /> 90 <Compile Include="MoveEvaluators\ThreeOptMoveTSPRoundedEuclideanPathEvaluator.cs" /> 89 <Compile Include="MoveEvaluators\ThreeOpt\TSPThreeOptRoundedEuclideanPathMoveEvaluator.cs" /> 90 <Compile Include="MoveEvaluators\ThreeOpt\TSPThreeOptEuclideanPathMoveEvaluator.cs" /> 91 <Compile Include="MoveEvaluators\ThreeOpt\TSPThreeOptGeoPathMoveEvaluator.cs" /> 92 <Compile Include="MoveEvaluators\TwoOpt\TSPTwoOptEuclideanPathMoveEvaluator.cs" /> 93 <Compile Include="MoveEvaluators\TwoOpt\TSPTwoOptGeoPathMoveEvaluator.cs" /> 94 <Compile Include="MoveEvaluators\TwoOpt\TSPTwoOptPathMoveEvaluator.cs" /> 95 <Compile Include="MoveEvaluators\TwoOpt\TSPTwoOptRoundedEuclideanPathMoveEvaluator.cs" /> 91 96 <Compile Include="TravelingSalesmanProblem.cs" /> 92 97 <Compile Include="TSPLIBTourParser.cs" /> … … 104 109 <Compile Include="Interfaces\ITSPPathEvaluator.cs" /> 105 110 <Compile Include="Interfaces\ITSPPathMoveEvaluator.cs" /> 106 <Compile Include="MoveEvaluators\T woOptMoveTSPRoundedEuclideanPathEvaluator.cs" />111 <Compile Include="MoveEvaluators\ThreeOpt\TSPThreeOptPathMoveEvaluator.cs" /> 107 112 <Compile Include="MoveEvaluators\TSPPathMoveEvaluator.cs" /> 108 113 <Compile Include="MoveEvaluators\TSPMoveEvaluator.cs" /> 109 <Compile Include="MoveEvaluators\TwoOptMoveTSPCoordinatesPathEvaluator.cs">110 <SubType>Code</SubType>111 </Compile>112 114 <Compile Include="TSPLIBParser.cs" /> 113 115 <Compile Include="Properties\AssemblyInfo.cs" /> -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/Interfaces/ITSPMoveEvaluator.cs
r3158 r3209 23 23 using HeuristicLab.Data; 24 24 using HeuristicLab.Optimization; 25 using System; 25 26 26 27 namespace HeuristicLab.Problems.TravelingSalesman { 27 28 public interface ITSPMoveEvaluator : ISingleObjectiveMoveEvaluator, IMoveOperator { 29 Type EvaluatorType { get; } 28 30 } 29 31 } -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TSPMoveEvaluator.cs
r3158 r3209 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 34 35 [StorableClass] 35 36 public abstract class TSPMoveEvaluator : SingleSuccessorOperator, ITSPMoveEvaluator, IMoveOperator { 37 public abstract Type EvaluatorType { get; } 38 36 39 public ILookupParameter<DoubleValue> QualityParameter { 37 40 get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; } -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TSPPathMoveEvaluator.cs
r3158 r3209 54 54 Parameters.Add(new LookupParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated (if it does not exist already) and used for evaluation, otherwise false.")); 55 55 } 56 57 public override IOperation Apply() { 58 Permutation permutation = PermutationParameter.ActualValue; 59 DoubleMatrix coordinates = CoordinatesParameter.ActualValue; 60 double relativeQualityDifference = 0; 61 if (UseDistanceMatrixParameter.ActualValue.Value) { 62 DoubleMatrix distanceMatrix = DistanceMatrixParameter.ActualValue; 63 if (distanceMatrix == null) { 64 distanceMatrix = CalculateDistanceMatrix(coordinates); 65 DistanceMatrixParameter.ActualValue = distanceMatrix; 66 } 67 relativeQualityDifference = EvaluateByDistanceMatrix(permutation, distanceMatrix); 68 } else relativeQualityDifference = EvaluateByCoordinates(permutation, coordinates); 69 DoubleValue moveQuality = MoveQualityParameter.ActualValue; 70 if (moveQuality == null) MoveQualityParameter.ActualValue = new DoubleValue(QualityParameter.ActualValue.Value + relativeQualityDifference); 71 else moveQuality.Value = QualityParameter.ActualValue.Value + relativeQualityDifference; 72 return base.Apply(); 73 } 74 75 protected abstract double CalculateDistance(double x1, double y1, double x2, double y2); 76 protected abstract double EvaluateByDistanceMatrix(Permutation permutation, DoubleMatrix distanceMatrix); 77 protected abstract double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates); 78 79 private DoubleMatrix CalculateDistanceMatrix(DoubleMatrix c) { 80 DoubleMatrix distanceMatrix = new DoubleMatrix(c.Rows, c.Rows); 81 for (int i = 0; i < distanceMatrix.Rows; i++) { 82 for (int j = 0; j < distanceMatrix.Columns; j++) 83 distanceMatrix[i, j] = CalculateDistance(c[i, 0], c[i, 1], c[j, 0], c[j, 1]); 84 } 85 return distanceMatrix; 86 } 56 87 } 57 88 } -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
r3199 r3209 253 253 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 254 254 ParameterizeEvaluator(); 255 UpdateMoveEvaluators(); 255 256 ParameterizeVisualizer(); 256 257 ClearDistanceMatrix(); … … 296 297 if (ApplicationManager.Manager != null) operators.AddRange(ApplicationManager.Manager.GetInstances<IPermutationOperator>()); 297 298 ParameterizeOperators(); 299 UpdateMoveEvaluators(); 298 300 InitializeMoveGenerators(); 299 301 } … … 308 310 op.ThreeOptMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_ThreeOptMoveParameter_ActualNameChanged); 309 311 } 312 } 313 } 314 private void UpdateMoveEvaluators() { 315 if (ApplicationManager.Manager != null) { 316 foreach (ITSPPathMoveEvaluator op in Operators.OfType<ITSPPathMoveEvaluator>().ToList()) 317 operators.Remove(op); 318 foreach (ITSPPathMoveEvaluator op in ApplicationManager.Manager.GetInstances<ITSPPathMoveEvaluator>()) 319 if (op.EvaluatorType == Evaluator.GetType()) { 320 operators.Add(op); 321 } 322 ParameterizeOperators(); 323 OnOperatorsChanged(); 310 324 } 311 325 } … … 347 361 op.DistanceMatrixParameter.ActualName = DistanceMatrixParameter.Name; 348 362 op.UseDistanceMatrixParameter.ActualName = UseDistanceMatrixParameter.Name; 363 op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 364 op.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName; 349 365 } 350 366 }
Note: See TracChangeset
for help on using the changeset viewer.