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 copied

Legend:

Unmodified
Added
Removed
  • branches/PTSP/HeuristicLab.Problems.PTSP/3.3/Improvers/PTSPEstimatedInversionLocalImprovement.cs

    r13469 r13470  
    3838  /// The operator tries to improve the probabilistic traveling salesman solution by swapping two randomly chosen edges for a certain number of times.
    3939  /// </remarks>
    40   [Item("PTSPExhaustiveInversionLocalImprovement", "An operator that improves probabilistic traveling salesman solutions. The operator tries to improve the probabilistic traveling salesman solution by swapping two randomly chosen edges for a certain number of times.")]
     40  [Item("PTSP Estimated Inversion Local Improvement", "An operator that improves probabilistic traveling salesman solutions. The operator tries to improve the probabilistic traveling salesman solution by swapping two randomly chosen edges for a certain number of times.")]
    4141  [StorableClass]
    42   public sealed class PTSPExhaustiveInversionLocalImprovement : SingleSuccessorOperator, IEstimatedPTSPOperator, ILocalImprovementOperator {
     42  public sealed class PTSPEstimatedInversionLocalImprovement : SingleSuccessorOperator, IEstimatedPTSPOperator, ILocalImprovementOperator {
    4343
    4444    public ILookupParameter<IntValue> LocalIterationsParameter {
     
    7979
    8080    [StorableConstructor]
    81     private PTSPExhaustiveInversionLocalImprovement(bool deserializing) : base(deserializing) { }
    82     private PTSPExhaustiveInversionLocalImprovement(PTSPExhaustiveInversionLocalImprovement original, Cloner cloner) : base(original, cloner) { }
    83     public PTSPExhaustiveInversionLocalImprovement()
     81    private PTSPEstimatedInversionLocalImprovement(bool deserializing) : base(deserializing) { }
     82    private PTSPEstimatedInversionLocalImprovement(PTSPEstimatedInversionLocalImprovement original, Cloner cloner) : base(original, cloner) { }
     83    public PTSPEstimatedInversionLocalImprovement()
    8484      : base() {
    8585      Parameters.Add(new LookupParameter<Permutation>("Permutation", "The solution as permutation."));
     
    9595
    9696    public override IDeepCloneable Clone(Cloner cloner) {
    97       return new PTSPExhaustiveInversionLocalImprovement(this, cloner);
     97      return new PTSPEstimatedInversionLocalImprovement(this, cloner);
    9898    }
    9999
    100     public static void Improve(Permutation assignment, DoubleMatrix distances, DoubleValue quality, IntValue localIterations, IntValue evaluatedSolutions, bool maximization, int maxIterations, CancellationToken cancellation, ItemList<BoolArray> realizations) {
     100    public static void Improve(Permutation assignment, DoubleMatrix distances, DoubleValue quality, IntValue localIterations, IntValue evaluatedSolutions, bool maximization, int maxIterations, ItemList<BoolArray> realizations, CancellationToken cancellation) {
    101101      var distanceM = (DistanceMatrix)distances;
     102      Func<int, int, double> distance = (a, b) => distanceM[a, b];
    102103      for (var i = localIterations.Value; i < maxIterations; i++) {
    103104        InversionMove bestMove = null;
     
    105106        double evaluations = 0.0;
    106107        foreach (var move in ExhaustiveInversionMoveGenerator.Generate(assignment)) {
    107           double moveQuality = PTSPEstimatedInversionMoveEvaluator.EvaluateByDistanceMatrix(assignment, move, distanceM, realizations);
    108           evaluations += 2 * (move.Index2 - move.Index1 + 1) / (double)assignment.Length;
     108          double moveQuality = PTSPEstimatedInversionMoveEvaluator.EvaluateMove(assignment, move, distance, realizations);
     109          evaluations += realizations.Count * 4.0 / (assignment.Length * assignment.Length);
    109110          if (maximization && moveQuality > bestQuality
    110111            || !maximization && moveQuality < bestQuality) {
     
    136137      }
    137138
    138       Improve(assignment, distances, quality, localIterations, evaluations, maximization, maxIterations, CancellationToken, realizations);
     139      Improve(assignment, distances, quality, localIterations, evaluations, maximization, maxIterations, realizations, CancellationToken);
    139140
    140141      localIterations.Value = 0;
Note: See TracChangeset for help on using the changeset viewer.