- Timestamp:
- 12/15/15 16:38:08 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PTSP/HeuristicLab.Problems.PTSP.Tests-3.3/PTSPMoveEvaluatorTest.cs
r13412 r13470 85 85 [TestProperty("Time", "short")] 86 86 public void InversionMoveEvaluatorTest() { 87 var beforeMatrix = EstimatedProbabilisticTravelingSalesmanProblem.Evaluate(tour, distances, realizations)[0]; 87 Func<int, int, double> distance = (a, b) => distances[a, b]; 88 double variance; 89 var beforeMatrix = EstimatedProbabilisticTravelingSalesmanProblem.Evaluate(tour, distance, realizations, out variance); 88 90 89 91 for (var i = 0; i < 500; i++) { 90 92 var move = StochasticInversionSingleMoveGenerator.Apply(tour, random); 91 var moveMatrix = PTSPEstimatedInversionMoveEvaluator.Evaluate ByDistanceMatrix(tour, move, distances, realizations);93 var moveMatrix = PTSPEstimatedInversionMoveEvaluator.EvaluateMove(tour, move, distance, realizations); 92 94 InversionManipulator.Apply(tour, move.Index1, move.Index2); 93 var afterMatrix = EstimatedProbabilisticTravelingSalesmanProblem.Evaluate(tour, distance s, realizations)[0];95 var afterMatrix = EstimatedProbabilisticTravelingSalesmanProblem.Evaluate(tour, distance, realizations, out variance); 94 96 95 97 Assert.IsTrue(Math.Abs(moveMatrix).IsAlmost(Math.Abs(afterMatrix - beforeMatrix)), … … 106 108 [TestProperty("Time", "short")] 107 109 public void InsertionMoveEvaluatorTest() { 108 var beforeMatrix = EstimatedProbabilisticTravelingSalesmanProblem.Evaluate(tour, distances, realizations)[0]; 109 110 Func<int, int, double> distance = (a, b) => distances[a, b]; 111 double variance; 112 var beforeMatrix = EstimatedProbabilisticTravelingSalesmanProblem.Evaluate(tour, distance, realizations, out variance); 110 113 for (var i = 0; i < 500; i++) { 111 114 var move = StochasticTranslocationSingleMoveGenerator.Apply(tour, random); 112 var moveMatrix = PTSPEstimatedInsertionMoveEvaluator.Evaluate ByDistanceMatrix(tour, move, distances, realizations);115 var moveMatrix = PTSPEstimatedInsertionMoveEvaluator.EvaluateMove(tour, move, distance, realizations); 113 116 TranslocationManipulator.Apply(tour, move.Index1, move.Index1, move.Index3); 114 var afterMatrix = EstimatedProbabilisticTravelingSalesmanProblem.Evaluate(tour, distance s, realizations)[0];117 var afterMatrix = EstimatedProbabilisticTravelingSalesmanProblem.Evaluate(tour, distance, realizations, out variance); 115 118 116 119 Assert.IsTrue(Math.Abs(moveMatrix).IsAlmost(Math.Abs(afterMatrix - beforeMatrix)), … … 122 125 } 123 126 } 124 125 [TestMethod]126 [TestCategory("Problems.ProbabilisticTravelingSalesman")]127 [TestProperty("Time", "short")]128 public void AnalyticalTest() {129 for (var i = 0; i < 10; i++) {130 var perm = new Permutation(PermutationTypes.RelativeUndirected, ProblemSize, random);131 var estimated = EstimatedProbabilisticTravelingSalesmanProblem.Evaluate(perm, distances, realizations)[0];132 133 var analytical = AnalyticalProbabilisticTravelingSalesmanProblem.Evaluate(perm, distances, probabilities);134 Console.WriteLine(Math.Abs(analytical - estimated));135 }136 }137 127 } 138 128 }
Note: See TracChangeset
for help on using the changeset viewer.