Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/20/17 20:41:33 (8 years ago)
Author:
abeham
Message:

#2457: working on identification of problem instances

Location:
branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/Permutation/LocalSearch/StaticAPI
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/Permutation/LocalSearch/StaticAPI/Exhaustive.cs

    r14552 r14690  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Threading;
    2425using HeuristicLab.Core;
     
    3334#endif
    3435
    35     public static Tuple<int, int> HillClimb(IRandom random, Encodings.PermutationEncoding.Permutation perm,
    36       ref double quality, bool maximization, Func<Encodings.PermutationEncoding.Permutation, CancellationToken, double> eval,
     36    public static IEnumerable<Tuple<Encodings.PermutationEncoding.Permutation, double, int>> HillClimb(IRandom random, Encodings.PermutationEncoding.Permutation perm,
     37      double quality, bool maximization, Func<Encodings.PermutationEncoding.Permutation, CancellationToken, double> eval,
    3738      CancellationToken token, bool[,] subspace = null) {
    3839      if (double.IsNaN(quality)) quality = eval(perm, token);
    39       Tuple<int, int> changes;
     40      IEnumerable<Tuple<Encodings.PermutationEncoding.Permutation, double, int>> localSearchPath;
    4041      switch (perm.PermutationType) {
    4142        case PermutationTypes.Absolute:
    42           changes = ExhaustiveSwap2.HillClimb(random, perm, ref quality, maximization, eval, token, subspace);
     43          localSearchPath = ExhaustiveSwap2.HillClimb(random, perm, quality, maximization, eval, token, subspace);
    4344          break;
    4445        case PermutationTypes.RelativeDirected:
    45           changes = Exhaustive1Shift.HillClimb(random, perm, ref quality, maximization, eval, token, subspace);
     46          localSearchPath = Exhaustive1Shift.HillClimb(random, perm, quality, maximization, eval, token, subspace);
    4647          break;
    4748        case PermutationTypes.RelativeUndirected:
    48           changes = Exhaustive2Opt.HillClimb(random, perm, ref quality, maximization, eval, token, subspace);
     49          localSearchPath = Exhaustive2Opt.HillClimb(random, perm, quality, maximization, eval, token, subspace);
    4950          break;
    5051        default: throw new ArgumentException(string.Format("Permutation type {0} is not known", perm.PermutationType));
    5152      }
    5253      if (VALIDATE && !perm.Validate()) throw new ArgumentException("HillClimb produced invalid child");
    53       return changes;
     54      return localSearchPath;
    5455    }
    5556  }
  • branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/Permutation/LocalSearch/StaticAPI/Exhaustive1Shift.cs

    r14552 r14690  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    2425using System.Threading;
     
    3031namespace HeuristicLab.Algorithms.MemPR.Permutation.LocalSearch {
    3132  public static class Exhaustive1Shift {
    32     public static Tuple<int, int> HillClimb(IRandom random, Encodings.PermutationEncoding.Permutation perm,
    33       ref double quality, bool maximization, Func<Encodings.PermutationEncoding.Permutation, CancellationToken, double> eval,
     33    public static IEnumerable<Tuple<Encodings.PermutationEncoding.Permutation, double, int>>
     34      HillClimb(IRandom random, Encodings.PermutationEncoding.Permutation perm,
     35      double quality, bool maximization, Func<Encodings.PermutationEncoding.Permutation, CancellationToken, double> eval,
    3436      CancellationToken token, bool[,] subspace = null) {
    3537      var evaluations = 0;
     
    4042      }
    4143      TranslocationMove lastSuccessMove = null;
    42       var steps = 0;
    4344      var neighborhood = ExhaustiveInsertionMoveGenerator.Generate(current).Shuffle(random).ToList();
    4445      while (true) {
     
    6263          evaluations++;
    6364          if (FitnessComparer.IsBetter(maximization, q, quality)) {
    64             steps++;
     65            yield return Tuple.Create(current, q, evaluations);
    6566            quality = q;
    6667            lastSuccessMove = shift;
     
    7475        if (lastSuccessMove == null) break;
    7576      }
    76       return Tuple.Create(evaluations, steps);
     77      yield return Tuple.Create(current, quality, evaluations);
    7778    }
    7879  }
  • branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/Permutation/LocalSearch/StaticAPI/Exhaustive2Opt.cs

    r14556 r14690  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    2425using System.Threading;
     
    3031namespace HeuristicLab.Algorithms.MemPR.Permutation.LocalSearch {
    3132  public static class Exhaustive2Opt {
    32     public static Tuple<int, int> HillClimb(IRandom random, Encodings.PermutationEncoding.Permutation perm,
    33       ref double quality, bool maximization, Func<Encodings.PermutationEncoding.Permutation, CancellationToken, double> eval,
     33    public static IEnumerable<Tuple<Encodings.PermutationEncoding.Permutation, double, int>>
     34      HillClimb(IRandom random, Encodings.PermutationEncoding.Permutation perm,
     35      double quality, bool maximization, Func<Encodings.PermutationEncoding.Permutation, CancellationToken, double> eval,
    3436      CancellationToken token, bool[,] subspace = null) {
    3537      var evaluations = 0;
     
    4042      }
    4143      InversionMove lastSuccessMove = null;
    42       var steps = 0;
    4344      var neighborhood = ExhaustiveInversionMoveGenerator.Generate(current).Shuffle(random).ToList();
    4445      while (true) {
     
    5960          evaluations++;
    6061          if (FitnessComparer.IsBetter(maximization, q, quality)) {
    61             steps++;
     62            yield return Tuple.Create(current, q, evaluations);
    6263            quality = q;
    6364            lastSuccessMove = opt;
     
    7172        if (lastSuccessMove == null) break;
    7273      }
    73       return Tuple.Create(evaluations, steps);
     74      yield return Tuple.Create(current, quality, evaluations);
    7475    }
    7576  }
  • branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/Permutation/LocalSearch/StaticAPI/ExhaustiveSwap2.cs

    r14552 r14690  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    2425using System.Threading;
     
    3031namespace HeuristicLab.Algorithms.MemPR.Permutation.LocalSearch {
    3132  public static class ExhaustiveSwap2 {
    32     public static Tuple<int, int> HillClimb(IRandom random, Encodings.PermutationEncoding.Permutation perm,
    33       ref double quality, bool maximization, Func<Encodings.PermutationEncoding.Permutation, CancellationToken, double> eval,
     33    public static IEnumerable<Tuple<Encodings.PermutationEncoding.Permutation, double, int>>
     34      HillClimb(IRandom random, Encodings.PermutationEncoding.Permutation perm,
     35      double quality, bool maximization, Func<Encodings.PermutationEncoding.Permutation, CancellationToken, double> eval,
    3436      CancellationToken token, bool[,] subspace = null) {
    3537      var evaluations = 0;
     
    4042      }
    4143      Swap2Move lastSuccessMove = null;
    42       var steps = 0;
    4344      var neighborhood = ExhaustiveSwap2MoveGenerator.Generate(current).Shuffle(random).ToList();
    4445      while (true) {
     
    5859          evaluations++;
    5960          if (FitnessComparer.IsBetter(maximization, q, quality)) {
    60             steps++;
     61            yield return Tuple.Create(current, q, evaluations);
    6162            quality = q;
    6263            lastSuccessMove = swap;
     
    7374        if (lastSuccessMove == null) break;
    7475      }
    75       return Tuple.Create(evaluations, steps);
     76      yield return Tuple.Create(current, quality, evaluations);
    7677    }
    7778  }
Note: See TracChangeset for help on using the changeset viewer.