Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/15/15 16:38:08 (9 years ago)
Author:
abeham
Message:

#2221:

  • implemented review comments
    • hid rng as private class, implemented djb2 hash function (hash function implementation may also change)
    • added missing probabilities
    • base class for instance providers
    • prebuild event events
    • build platforms
    • unit test will be removed on trunk integration
    • corrected assembly file version
    • distance calculator parameter was not hidden, can be changed by user, updates distance matrix
    • fixed performance problems (ouch!) also for estimated ptsp (inlined GetDistance method)
  • added moves (full evaluation) for analytical tsp
  • added local improvement operators for analytical ptsp
  • added recalculation of distance matrix when parameters change
  • still lots of other changes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PTSP/HeuristicLab.Problems.PTSP.Tests-3.3/PTSPMoveEvaluatorTest.cs

    r13412 r13470  
    8585    [TestProperty("Time", "short")]
    8686    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);
    8890
    8991      for (var i = 0; i < 500; i++) {
    9092        var move = StochasticInversionSingleMoveGenerator.Apply(tour, random);
    91         var moveMatrix = PTSPEstimatedInversionMoveEvaluator.EvaluateByDistanceMatrix(tour, move, distances, realizations);
     93        var moveMatrix = PTSPEstimatedInversionMoveEvaluator.EvaluateMove(tour, move, distance, realizations);
    9294        InversionManipulator.Apply(tour, move.Index1, move.Index2);
    93         var afterMatrix = EstimatedProbabilisticTravelingSalesmanProblem.Evaluate(tour, distances, realizations)[0];
     95        var afterMatrix = EstimatedProbabilisticTravelingSalesmanProblem.Evaluate(tour, distance, realizations, out variance);
    9496
    9597        Assert.IsTrue(Math.Abs(moveMatrix).IsAlmost(Math.Abs(afterMatrix - beforeMatrix)),
     
    106108    [TestProperty("Time", "short")]
    107109    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);
    110113      for (var i = 0; i < 500; i++) {
    111114        var move = StochasticTranslocationSingleMoveGenerator.Apply(tour, random);
    112         var moveMatrix = PTSPEstimatedInsertionMoveEvaluator.EvaluateByDistanceMatrix(tour, move, distances, realizations);
     115        var moveMatrix = PTSPEstimatedInsertionMoveEvaluator.EvaluateMove(tour, move, distance, realizations);
    113116        TranslocationManipulator.Apply(tour, move.Index1, move.Index1, move.Index3);
    114         var afterMatrix = EstimatedProbabilisticTravelingSalesmanProblem.Evaluate(tour, distances, realizations)[0];
     117        var afterMatrix = EstimatedProbabilisticTravelingSalesmanProblem.Evaluate(tour, distance, realizations, out variance);
    115118
    116119        Assert.IsTrue(Math.Abs(moveMatrix).IsAlmost(Math.Abs(afterMatrix - beforeMatrix)),
     
    122125      }
    123126    }
    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     }
    137127  }
    138128}
Note: See TracChangeset for help on using the changeset viewer.