Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/22/11 15:18:20 (14 years ago)
Author:
abeham
Message:

#1344

  • Adapted all algorithms to count evaluated solutions / moves and outside of the parallel region
  • Used the same pattern in every algorithm: Initialize and collect the variable in the Algorithm and increment it in the main loops and main operators
Location:
trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearch.cs

    r4722 r5356  
    2727using HeuristicLab.Core;
    2828using HeuristicLab.Data;
     29using HeuristicLab.Operators;
    2930using HeuristicLab.Optimization;
    3031using HeuristicLab.Optimization.Operators;
     
    134135    }
    135136    private TabuSearchMainLoop MainLoop {
    136       get { return (TabuSearchMainLoop)SolutionsCreator.Successor; }
     137      get {
     138        return (TabuSearchMainLoop)(
     139          (ResultsCollector)(
     140            (VariableCreator)SolutionsCreator.Successor
     141          ).Successor
     142        ).Successor;
     143      }
    137144    }
    138145    [Storable]
     
    158165      RandomCreator randomCreator = new RandomCreator();
    159166      SolutionsCreator solutionsCreator = new SolutionsCreator();
    160       TabuSearchMainLoop tsMainLoop = new TabuSearchMainLoop();
     167      VariableCreator variableCreator = new VariableCreator();
     168      ResultsCollector resultsCollector = new ResultsCollector();
     169      TabuSearchMainLoop mainLoop = new TabuSearchMainLoop();
    161170      OperatorGraph.InitialOperator = randomCreator;
    162171
     
    169178
    170179      solutionsCreator.NumberOfSolutions = new IntValue(1);
    171       solutionsCreator.Successor = tsMainLoop;
    172 
    173       tsMainLoop.MoveGeneratorParameter.ActualName = MoveGeneratorParameter.Name;
    174       tsMainLoop.MoveMakerParameter.ActualName = MoveMakerParameter.Name;
    175       tsMainLoop.MoveEvaluatorParameter.ActualName = MoveEvaluatorParameter.Name;
    176       tsMainLoop.TabuCheckerParameter.ActualName = TabuCheckerParameter.Name;
    177       tsMainLoop.TabuMakerParameter.ActualName = TabuMakerParameter.Name;
    178       tsMainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
    179       tsMainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
    180       tsMainLoop.ResultsParameter.ActualName = "Results";
    181       tsMainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
     180      solutionsCreator.Successor = variableCreator;
     181
     182      variableCreator.Name = "Initialize EvaluatedMoves";
     183      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedMoves", new IntValue()));
     184      variableCreator.Successor = resultsCollector;
     185
     186      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Moves", null, "EvaluatedMoves"));
     187      resultsCollector.ResultsParameter.ActualName = "Results";
     188      resultsCollector.Successor = mainLoop;
     189
     190      mainLoop.MoveGeneratorParameter.ActualName = MoveGeneratorParameter.Name;
     191      mainLoop.MoveMakerParameter.ActualName = MoveMakerParameter.Name;
     192      mainLoop.MoveEvaluatorParameter.ActualName = MoveEvaluatorParameter.Name;
     193      mainLoop.TabuCheckerParameter.ActualName = TabuCheckerParameter.Name;
     194      mainLoop.TabuMakerParameter.ActualName = TabuMakerParameter.Name;
     195      mainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
     196      mainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
     197      mainLoop.ResultsParameter.ActualName = "Results";
     198      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
     199      mainLoop.EvaluatedMovesParameter.ActualName = "EvaluatedMoves";
    182200
    183201      moveQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
  • trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearchMainLoop.cs

    r5354 r5356  
    8383      get { return (ValueLookupParameter<VariableCollection>)Parameters["Results"]; }
    8484    }
     85    public LookupParameter<IntValue> EvaluatedMovesParameter {
     86      get { return (LookupParameter<IntValue>)Parameters["EvaluatedMoves"]; }
     87    }
    8588    #endregion
    8689
     
    131134      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze the solution and moves."));
    132135      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
     136      Parameters.Add(new LookupParameter<IntValue>("EvaluatedMoves", "The number of evaluated moves."));
    133137      #endregion
    134138
     
    162166
    163167      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0))); // Class TabuSearch expects this to be called Iterations
    164       variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedMoves", new IntValue(0)));
    165168      variableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("EmptyNeighborhood", new BoolValue(false)));
    166169      variableCreator.CollectedValues.Add(new ValueParameter<ItemList<IItem>>("TabuList", new ItemList<IItem>()));
     
    178181      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Iterations"));
    179182      resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    180       resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Moves", null, "EvaluatedMoves"));
    181183      resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
    182184
     
    193195
    194196      subScopesCounter.Name = "Increment EvaluatedMoves";
    195       subScopesCounter.ValueParameter.ActualName = "EvaluatedMoves";
     197      subScopesCounter.ValueParameter.ActualName = EvaluatedMovesParameter.Name;
    196198
    197199      moveQualitySorter.DescendingParameter.ActualName = MaximizationParameter.Name;
Note: See TracChangeset for help on using the changeset viewer.