Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/23/17 10:42:58 (8 years ago)
Author:
abeham
Message:

#2457: working on identification of problem instances

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

Legend:

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

    r14690 r14691  
    2828using HeuristicLab.Optimization;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Problems.QuadraticAssignment;
    3031
    3132namespace HeuristicLab.Algorithms.MemPR.Permutation.LocalSearch {
     
    5455      var quality = context.Solution.Fitness;
    5556      try {
     57
     58        var min = 0.0;
     59        var max = 1.0;
     60        var qap = context.Problem as QuadraticAssignmentProblem;
     61        if (qap != null) {
     62          min = qap.LowerBound.Value;
     63          max = qap.AverageQuality.Value;
     64        }
     65
    5666        var path = new List<Tuple<Encodings.PermutationEncoding.Permutation, double>>();
    57         path.Add(Tuple.Create((Encodings.PermutationEncoding.Permutation)context.Solution.Solution.Clone(), quality));
     67        path.Add(Tuple.Create((Encodings.PermutationEncoding.Permutation)context.Solution.Solution.Clone(), (quality - min) / (max - min)));
    5868
    5969        var result = Exhaustive.HillClimb(context.Random, context.Solution.Solution, quality,
    6070          context.Maximization, context.Evaluate, CancellationToken.None);
    61 
    62         Tuple<Encodings.PermutationEncoding.Permutation, double, int> last = null;
     71       
     72        var evaluations = 0;
    6373        foreach (var step in result) {
    64           path.Add(Tuple.Create((Encodings.PermutationEncoding.Permutation)step.Item1.Clone(), step.Item2));
    65           last = step;
     74          path.Add(Tuple.Create((Encodings.PermutationEncoding.Permutation)step.Item1.Clone(), (step.Item2 - min) / (max - min)));
     75          evaluations = step.Item3; // last one will be actual evaluations
    6676        }
    6777        context.LocalSearchPaths.AddPath(path);
    68         context.IncrementEvaluatedSolutions(last.Item3);
     78        context.IncrementEvaluatedSolutions(evaluations);
    6979        context.Iterations = path.Count - 2;
    7080      } finally {
  • branches/PerformanceComparison/HeuristicLab.Algorithms.MemPR/3.3/Permutation/LocalSearch/ExhaustiveHillClimbSubspace.cs

    r14690 r14691  
    2828using HeuristicLab.Optimization;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Problems.QuadraticAssignment;
    3031
    3132namespace HeuristicLab.Algorithms.MemPR.Permutation.LocalSearch {
     
    5455      var quality = context.Solution.Fitness;
    5556      try {
     57        var min = 0.0;
     58        var max = 1.0;
     59        var qap = context.Problem as QuadraticAssignmentProblem;
     60        if (qap != null) {
     61          min = qap.LowerBound.Value;
     62          max = qap.AverageQuality.Value;
     63        }
     64
    5665        var path = new List<Tuple<Encodings.PermutationEncoding.Permutation, double>>();
    57         path.Add(Tuple.Create((Encodings.PermutationEncoding.Permutation)context.Solution.Solution.Clone(), quality));
     66        path.Add(Tuple.Create((Encodings.PermutationEncoding.Permutation)context.Solution.Solution.Clone(), (quality - min) / (max - min)));
    5867
    5968        var result = Exhaustive.HillClimb(context.Random, context.Solution.Solution, quality,
    6069          context.Maximization, context.Evaluate, CancellationToken.None, context.Subspace.Subspace);
    6170
    62         Tuple<Encodings.PermutationEncoding.Permutation, double, int> last = null;
     71        var evaluations = 0;
    6372        foreach (var step in result) {
    64           path.Add(Tuple.Create((Encodings.PermutationEncoding.Permutation)step.Item1.Clone(), step.Item2));
    65           last = step;
     73          path.Add(Tuple.Create((Encodings.PermutationEncoding.Permutation)step.Item1.Clone(), (step.Item2 - min) / (max - min)));
     74          evaluations = step.Item3; // last one will be actual evaluations
    6675        }
    6776        context.LocalSearchPaths.AddPath(path);
    68         context.IncrementEvaluatedSolutions(last.Item3);
     77        context.IncrementEvaluatedSolutions(evaluations);
    6978        context.Iterations = path.Count - 2;
    7079      } finally {
Note: See TracChangeset for help on using the changeset viewer.