Free cookie consent management tool by TermsFeed Policy Generator

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

#2457: working on identification of problem instances

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.