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.LocalSearch/3.3
Files:
2 edited

Legend:

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

    r4722 r5356  
    2727using HeuristicLab.Core;
    2828using HeuristicLab.Data;
     29using HeuristicLab.Operators;
    2930using HeuristicLab.Optimization;
    3031using HeuristicLab.Optimization.Operators;
     
    117118    }
    118119    private LocalSearchMainLoop MainLoop {
    119       get { return (LocalSearchMainLoop)SolutionsCreator.Successor; }
     120      get {
     121        return (LocalSearchMainLoop)(
     122          (ResultsCollector)(
     123            (VariableCreator)SolutionsCreator.Successor
     124          ).Successor
     125        ).Successor;
     126      }
    120127    }
    121128    [Storable]
     
    150157      RandomCreator randomCreator = new RandomCreator();
    151158      SolutionsCreator solutionsCreator = new SolutionsCreator();
    152       LocalSearchMainLoop lsMainLoop = new LocalSearchMainLoop();
     159      VariableCreator variableCreator = new VariableCreator();
     160      ResultsCollector resultsCollector = new ResultsCollector();
     161      LocalSearchMainLoop mainLoop = new LocalSearchMainLoop();
    153162      OperatorGraph.InitialOperator = randomCreator;
    154163
     
    161170
    162171      solutionsCreator.NumberOfSolutions = new IntValue(1);
    163       solutionsCreator.Successor = lsMainLoop;
    164 
    165       lsMainLoop.MoveGeneratorParameter.ActualName = MoveGeneratorParameter.Name;
    166       lsMainLoop.MoveMakerParameter.ActualName = MoveMakerParameter.Name;
    167       lsMainLoop.MoveEvaluatorParameter.ActualName = MoveEvaluatorParameter.Name;
    168       lsMainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
    169       lsMainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
    170       lsMainLoop.ResultsParameter.ActualName = "Results";
    171       lsMainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
     172      solutionsCreator.Successor = variableCreator;
     173
     174      variableCreator.Name = "Initialize EvaluatedMoves";
     175      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedMoves", new IntValue()));
     176      variableCreator.Successor = resultsCollector;
     177
     178      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Moves", null, "EvaluatedMoves"));
     179      resultsCollector.ResultsParameter.ActualName = "Results";
     180      resultsCollector.Successor = mainLoop;
     181
     182      mainLoop.MoveGeneratorParameter.ActualName = MoveGeneratorParameter.Name;
     183      mainLoop.MoveMakerParameter.ActualName = MoveMakerParameter.Name;
     184      mainLoop.MoveEvaluatorParameter.ActualName = MoveEvaluatorParameter.Name;
     185      mainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
     186      mainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
     187      mainLoop.ResultsParameter.ActualName = "Results";
     188      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
     189      mainLoop.EvaluatedMovesParameter.ActualName = "EvaluatedMoves";
    172190
    173191      moveQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
  • trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchMainLoop.cs

    r5353 r5356  
    7070      get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
    7171    }
    72 
    73     private ScopeParameter CurrentScopeParameter {
    74       get { return (ScopeParameter)Parameters["CurrentScope"]; }
    75     }
    76     public IScope CurrentScope {
    77       get { return CurrentScopeParameter.ActualValue; }
     72    public LookupParameter<IntValue> EvaluatedMovesParameter {
     73      get { return (LookupParameter<IntValue>)Parameters["EvaluatedMoves"]; }
    7874    }
    7975    #endregion
     
    107103
    108104      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze the solution and moves."));
    109       Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the TS should be applied."));
     105      Parameters.Add(new LookupParameter<IntValue>("EvaluatedMoves", "The number of evaluated moves."));
    110106      #endregion
    111107
     
    137133      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0))); // Class LocalSearch expects this to be called Iterations
    138134      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("BestQuality", new DoubleValue(0)));
    139       variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedMoves", new IntValue(0)));
    140135
    141136      bestQualityInitializer.Name = "Initialize BestQuality";
     
    149144      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Iterations"));
    150145      resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    151       resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Moves", null, "EvaluatedMoves"));
    152146      resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
    153147
     
    161155
    162156      subScopesCounter.Name = "Increment EvaluatedMoves";
    163       subScopesCounter.ValueParameter.ActualName = "EvaluatedMoves";
     157      subScopesCounter.ValueParameter.ActualName = EvaluatedMovesParameter.Name;
    164158
    165159      bestSelector.CopySelected = new BoolValue(false);
Note: See TracChangeset for help on using the changeset viewer.