Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/03/15 23:42:33 (9 years ago)
Author:
abeham
Message:

#2444: changed counting to solution evaluation equivalents in order to avoid running into int.MaxValue for long runs

Location:
trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSeachOperator.cs

    r12810 r12835  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    9293    }
    9394
    94     public ILookupParameter<IntValue> EvaluatedMovesParameter {
    95       get { return (ILookupParameter<IntValue>)Parameters["EvaluatedMoves"]; }
     95    public ILookupParameter<IntValue> EvaluatedSolutionsParameter {
     96      get { return (ILookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
     97    }
     98
     99    public ILookupParameter<DoubleValue> EvaluatedSolutionEquivalentsParameter {
     100      get { return (ILookupParameter<DoubleValue>)Parameters["EvaluatedSolutionEquivalents"]; }
    96101    }
    97102    #endregion
     
    121126      Parameters.Add(new ValueLookupParameter<IntValue>("AlternativeAspirationTenure", "The time t that a move will be remembered for the alternative aspiration condition."));
    122127      Parameters.Add(new LookupParameter<BoolValue>("AllMovesTabu", "Indicates that all moves are tabu."));
    123       Parameters.Add(new LookupParameter<IntValue>("EvaluatedMoves", "The number of move evaluations made."));
     128      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of evaluated solutions."));
     129      Parameters.Add(new LookupParameter<DoubleValue>("EvaluatedSolutionEquivalents", "The number of evaluated solution equivalents."));
    124130    }
    125131
     
    135141        Parameters.Add(new LookupParameter<BoolValue>("AllMovesTabu", "Indicates that all moves are tabu."));
    136142      }
    137       if (!Parameters.ContainsKey("EvaluatedMoves")) {
    138         Parameters.Add(new LookupParameter<IntValue>("EvaluatedMoves", "The number of move evaluations made."));
     143      if (!Parameters.ContainsKey("EvaluatedSolutions")) {
     144        Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of evaluated solutions."));
     145      }
     146      if (!Parameters.ContainsKey("EvaluatedSolutionEquivalents")) {
     147        Parameters.Add(new LookupParameter<DoubleValue>("EvaluatedSolutionEquivalents", "The number of evaluated solution equivalents."));
    139148      }
    140149      #endregion
     
    171180      bool already_aspired = false;
    172181
    173       var evaluatedMoves = 0;
     182      double evaluations = EvaluatedSolutionsParameter.ActualValue.Value;
    174183      foreach (Swap2Move move in ExhaustiveSwap2MoveGenerator.Generate(solution)) {
    175184        double moveQuality;
    176185        if (lastMove == null) {
    177186          moveQuality = QAPSwap2MoveEvaluator.Apply(solution, move, weights, distances);
    178           evaluatedMoves++;
     187          evaluations += 4.0 / solution.Length;
    179188        } else if (allMovesTabu) moveQuality = moveQualityMatrix[move.Index1, move.Index2];
    180189        else {
    181190          moveQuality = QAPSwap2MoveEvaluator.Apply(solution, move, moveQualityMatrix[move.Index1, move.Index2], weights, distances, lastMove);
    182           evaluatedMoves++;
     191          if (move.Index1 == lastMove.Index1 || move.Index2 == lastMove.Index1 || move.Index1 == lastMove.Index2 || move.Index2 == lastMove.Index2)
     192            evaluations += 4.0 / solution.Length;
     193          else evaluations += 2.0 / (solution.Length * solution.Length);
    183194        }
    184195
     
    214225      }
    215226
    216       EvaluatedMovesParameter.ActualValue.Value += evaluatedMoves;
     227      EvaluatedSolutionEquivalentsParameter.ActualValue.Value = evaluations;
     228      EvaluatedSolutionsParameter.ActualValue.Value = (int)Math.Ceiling(evaluations);
    217229
    218230      allMovesTabu = bestMove == null;
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSearch.cs

    r12810 r12835  
    168168      VariableCreator variableCreator = new VariableCreator();
    169169      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0)));
    170       variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
    171       variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedMoves", new IntValue(0)));
     170      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(1)));
     171      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("EvaluatedSolutionEquivalents", new DoubleValue(1)));
    172172
    173173      ResultsCollector resultsCollector = new ResultsCollector();
    174174      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iterations", "The actual iteration."));
    175       resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of full solution evaluations."));
    176       resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedMoves", "The number of move evaluations."));
     175      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "Number of evaluated solutions."));
    177176
    178177      solutionsCreator = new SolutionsCreator();
    179178      solutionsCreator.NumberOfSolutions = new IntValue(1);
    180 
    181       IntCounter counter = new IntCounter();
    182       counter.ValueParameter.ActualName = "EvaluatedSolutions";
    183       counter.Increment = new IntValue(1);
    184179
    185180      Placeholder analyzer = new Placeholder();
     
    202197      mainOperator.ShortTermMemoryParameter.ActualName = "ShortTermMemory";
    203198      mainOperator.UseAlternativeAspirationParameter.ActualName = UseAlternativeAspirationParameter.Name;
    204       mainOperator.EvaluatedMovesParameter.ActualName = "EvaluatedMoves";
     199      mainOperator.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
     200      mainOperator.EvaluatedSolutionEquivalentsParameter.ActualName = "EvaluatedSolutionEquivalents";
    205201
    206202      ConditionalBranch qualityStopBranch = new ConditionalBranch();
     
    235231      variableCreator.Successor = resultsCollector;
    236232      resultsCollector.Successor = solutionsCreator;
    237       solutionsCreator.Successor = counter;
    238       counter.Successor = analyzer;
     233      solutionsCreator.Successor = analyzer;
    239234      analyzer.Successor = ussp;
    240235      ussp.Operator = mainOperator;
Note: See TracChangeset for help on using the changeset viewer.