Changeset 12810


Ignore:
Timestamp:
07/30/15 14:56:55 (4 years ago)
Author:
abeham
Message:

#2444: Added evaluation output to RTS

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

    r12012 r12810  
    9090    private ILookupParameter<BoolValue> AllMovesTabuParameter {
    9191      get { return (ILookupParameter<BoolValue>)Parameters["AllMovesTabu"]; }
     92    }
     93
     94    public ILookupParameter<IntValue> EvaluatedMovesParameter {
     95      get { return (ILookupParameter<IntValue>)Parameters["EvaluatedMoves"]; }
    9296    }
    9397    #endregion
     
    117121      Parameters.Add(new ValueLookupParameter<IntValue>("AlternativeAspirationTenure", "The time t that a move will be remembered for the alternative aspiration condition."));
    118122      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."));
    119124    }
    120125
     
    129134      if (!Parameters.ContainsKey("AllMovesTabu")) {
    130135        Parameters.Add(new LookupParameter<BoolValue>("AllMovesTabu", "Indicates that all moves are tabu."));
     136      }
     137      if (!Parameters.ContainsKey("EvaluatedMoves")) {
     138        Parameters.Add(new LookupParameter<IntValue>("EvaluatedMoves", "The number of move evaluations made."));
    131139      }
    132140      #endregion
     
    163171      bool already_aspired = false;
    164172
     173      var evaluatedMoves = 0;
    165174      foreach (Swap2Move move in ExhaustiveSwap2MoveGenerator.Generate(solution)) {
    166175        double moveQuality;
    167         if (lastMove == null)
     176        if (lastMove == null) {
    168177          moveQuality = QAPSwap2MoveEvaluator.Apply(solution, move, weights, distances);
    169         else if (allMovesTabu) moveQuality = moveQualityMatrix[move.Index1, move.Index2];
    170         else moveQuality = QAPSwap2MoveEvaluator.Apply(solution, move, moveQualityMatrix[move.Index1, move.Index2], weights, distances, lastMove);
     178          evaluatedMoves++;
     179        } else if (allMovesTabu) moveQuality = moveQualityMatrix[move.Index1, move.Index2];
     180        else {
     181          moveQuality = QAPSwap2MoveEvaluator.Apply(solution, move, moveQualityMatrix[move.Index1, move.Index2], weights, distances, lastMove);
     182          evaluatedMoves++;
     183        }
    171184
    172185        moveQualityMatrix[move.Index1, move.Index2] = moveQuality;
     
    200213        }
    201214      }
     215
     216      EvaluatedMovesParameter.ActualValue.Value += evaluatedMoves;
    202217
    203218      allMovesTabu = bestMove == null;
  • trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSearch.cs

    r12504 r12810  
    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)));
    170172
    171173      ResultsCollector resultsCollector = new ResultsCollector();
    172174      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."));
    173177
    174178      solutionsCreator = new SolutionsCreator();
    175179      solutionsCreator.NumberOfSolutions = new IntValue(1);
     180
     181      IntCounter counter = new IntCounter();
     182      counter.ValueParameter.ActualName = "EvaluatedSolutions";
     183      counter.Increment = new IntValue(1);
    176184
    177185      Placeholder analyzer = new Placeholder();
     
    194202      mainOperator.ShortTermMemoryParameter.ActualName = "ShortTermMemory";
    195203      mainOperator.UseAlternativeAspirationParameter.ActualName = UseAlternativeAspirationParameter.Name;
     204      mainOperator.EvaluatedMovesParameter.ActualName = "EvaluatedMoves";
    196205
    197206      ConditionalBranch qualityStopBranch = new ConditionalBranch();
     
    226235      variableCreator.Successor = resultsCollector;
    227236      resultsCollector.Successor = solutionsCreator;
    228       solutionsCreator.Successor = analyzer;
     237      solutionsCreator.Successor = counter;
     238      counter.Successor = analyzer;
    229239      analyzer.Successor = ussp;
    230240      ussp.Operator = mainOperator;
Note: See TracChangeset for help on using the changeset viewer.